|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hello
I have written the following code. Code: #include<stdio.h> #include<conio.h> void main() { int i = 0, a = 5, b = 6; i = a - - b; printf("i = %d", i); } When I execute this program, I have got an error message "LValue Required". Can any one explain what does that mean. Please guide. Thanks. |
| Sponsored Links |
|
|
|
|||||
|
The minus-operator is read from right to left, and in your code does one of the minus-operations miss a value on the left side. It's on line six, where you're having to minus-operators in a row:
Code:
i = a - - b; Code:
i = a - b; Another thing is your coding style. You should try staying to the standards, and don't be using non-compiler-independent libraries like conio.h. Your main-function is also wrong. It shall return an integer, and not nothing.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||
|
Thank you for your guidance.
But I don't understand "Non-compiler independent libraries" like conio.h. Why can't I use it? If I want to use a function like getch() then which library should be included? Why should main() function return an integer value? What it does when we use void? Sorry, I am a beginner to C. Please guide. |
|
|||||
|
Quote:
If you just want it to run on the platform you're currently using, then do it. You just have to keep in mind, that it's not a standard library. Quote:
The C standard is not online, so this is the best link I could find regarding C and the main()-function: FGA: "void main()" is not legal in C++ but is legal in C Quote:
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Work required to host a Search Engine | TcM | Search Engines | 19 | 06-13-2008 10:29 AM |
| Are IDEs required? | photray94 | Java Help | 6 | 05-12-2008 01:21 PM |
| DNS script - required! | Walls | Request Services (Paid) | 0 | 02-11-2008 02:43 AM |
| Programmer required | yertle | General Programming | 1 | 12-02-2007 04:33 AM |
| *** Programmer Required *** | gsm-tools | Request Services (Paid) | 2 | 10-27-2007 06:24 PM |
| Xav | ........ | 1357.94 |
| MeTh0Dz|Reb0rn | ........ | 1083.85 |
| WingedPanther | ........ | 919.18 |
| morefood2001 | ........ | 909.18 |
| marwex89 | ........ | 906.86 |
| John | ........ | 902.37 |
| Brandon W | ........ | 789.89 |
| chili5 | ........ | 312.39 |
| Steve.L | ........ | 264.99 |
| dcs | ........ | 240.34 |
Goal: 100,000 Posts
Complete: 83%