Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

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.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-05-2008, 12:56 AM
Goodluck Goodluck is offline
Newbie
 
Join Date: Mar 2008
Posts: 13
Rep Power: 0
Goodluck is on a distinguished road
Default LValue Required

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-05-2008, 01:52 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default Re: LValue Required

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;
Either remove one of the minuses, or put something in between. Here is it with one of them removed:
Code:
i = a - b;
That would work.

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.
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-05-2008, 03:15 AM
Goodluck Goodluck is offline
Newbie
 
Join Date: Mar 2008
Posts: 13
Rep Power: 0
Goodluck is on a distinguished road
Default Re: LValue Required

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-05-2008, 05:16 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default Re: LValue Required

Quote:
Originally Posted by Goodluck
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?
conio.h is not a part of the C programming language. It was originally made for the old MS-DOS compilers, but has been ported to newer platforms through the time, but it's by no mean cross-platform, so if you're developing for multiple platforms, this is not the right library to use.
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:
Originally Posted by Goodluck
Why should main() function return an integer value? What it does when we use void?
I was actually wrong on this one. I checked the C standard, and realized that it's actually up to the user (or compiler) how the main()-function shall be implemented in C. It's not like that in C++. In C++ you have to implement it using an integer as a return, and that's why I assumed it was the same in C.
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:
Originally Posted by Goodluck
Sorry, I am a beginner to C. Please guide.
Don't apologize, we all start somewhere. It's good that you're asking these questions. Many beginners would just think "okay," and just do it, without actually understanding it.
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-05-2008, 06:10 AM
Goodluck Goodluck is offline
Newbie
 
Join Date: Mar 2008
Posts: 13
Rep Power: 0
Goodluck is on a distinguished road
Default Re: LValue Required

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Work required to host a Search Engine TcM Search Engines 19 06-13-2008 11:29 AM
Are IDEs required? photray94 Java Help 6 05-12-2008 02:21 PM
DNS script - required! Walls Request Services (Paid) 0 02-11-2008 03:43 AM
Programmer required yertle General Programming 1 12-02-2007 05:33 AM
*** Programmer Required *** gsm-tools Request Services (Paid) 2 10-27-2007 07:24 PM


All times are GMT -5. The time now is 11:13 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 101%


Complete - Celebrate!

Ads