473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Error: Lvalue required in function main

1
I started using C just today and I am having a problem with strrev() function.

Here are my codes:

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4.  
  5. main()
  6.  
  7. {
  8. char a[20], b[20];
  9. clrscr();
  10. printf("Please enter your name: ");
  11. scanf("%s", &a);
  12. b=strrev(a);
  13. printf("Thanks. Your name when spelled backwards is %s.", b);
  14. getch();
  15. return(0);
  16. }
  17.  
When I try to run it, it gives me the Error: Lvalue required in function main. I've been trying everything and it just won't work. What shall I do? :(
Jan 10 '08 #1
4 11710
Meetee
931 Expert Mod 512MB
I started using C just today and I am having a problem with strrev() function.

Here are my codes:

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4.  
  5. main()
  6.  
  7. {
  8. char a[20], b[20];
  9. clrscr();
  10. printf("Please enter your name: ");
  11. scanf("%s", &a);
  12. b=strrev(a);
  13. printf("Thanks. Your name when spelled backwards is %s.", b);
  14. getch();
  15. return(0);
  16. }
  17.  
When I try to run it, it gives me the Error: Lvalue required in function main. I've been trying everything and it just won't work. What shall I do? :(
Write int main() and return 0; at the end!
Jan 10 '08 #2
instead of creating char b[100] array , create a pointer say char *b; and make the pointer to refer the array a[100].
now you will get the reverse string output.


.
.
.
char *b;
b=strrev(a);
printf("%s",b);
.
.
.
Jan 21 '12 #3
the function should return a value. as you have returned 0, you should give the return type as int.
Jan 21 '12 #4
no it is not the problem with pointers....
Jan 21 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Michael Ovetsky | last post by:
Consider: int g(){int b=1; return b;} int main() { int d=2; g()=d; }
14
by: Akhil | last post by:
plz c d following code #include<stdio.h> void main() { int x=4,y=1; y=x++++; //gives error message lvalue required y=x++ + ++y;//no errors
8
by: fei.liu | last post by:
I have the following source code. It seems wierd to me why gca's value cannot be reassigned. It's afterall a pointer and has a pointer value. I am aware that the standard says it's not allowed. But...
6
by: Lighter | last post by:
How to read "The lvalue-to-rvalue, array-to-pointer, and function-to- pointer standard conversionsare not applied to the left expressions"? In 5.18 Comma operator of the C++ standard, there is a...
22
by: clicwar | last post by:
A simple program with operator overloading and copy constructor: #include <iostream> #include <string> using namespace std; class Vector { private: float x,y; public: Vector(float u, float...
10
by: subramanian100in | last post by:
consider the following program: #include <iostream> using namespace std; class my_complex { public: friend ostream & operator<<(ostream &os, const my_complex &c);
63
by: Kapteyn's Star | last post by:
Hi newsgroup The program here given is refused by GCC with a error i cannot understand. It says rnd00.c: In function ‘main’: rnd00.c:26: error: expected expression before ‘]’ token ...
11
by: markryde | last post by:
Hello, Followed here is a simplified code example of something which I try to implement; in essence , I want to assign a value to a return value of a method is C. I know, of course, that in this...
4
by: ramesh nambiar reloaded | last post by:
#include<stdio.h> #include<string.h> #include<conio.h> #include<dos.h> // #include<object.h> const char *hex = "0123456789ABCDEF"; char *bin2hex(char *string); int...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.