473,395 Members | 1,689 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,395 software developers and data experts.

Lvalue required in function main what can i do !!

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. int main()
  3. {
  4. typedef struct {
  5. char name[10];
  6. int salary;
  7. }me;
  8. me a;
  9. a.name="ehab";
  10. a.salary=5789;
  11. printf("%s",a.name);
  12. printf("%d",a.salary);
  13. return 0;
  14. }
Jan 6 '11 #1
5 3542
donbock
2,426 Expert 2GB
Please enclose your code in CODE tags.
Move the typedef out of the main function.
By the way, you should print a newline ("\n") in at least the second printf, if not both.
Jan 6 '11 #2
i move the typedef but there is no change
i can't understand what is the meaning of enclose code in CODE tags
Jan 6 '11 #3
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. typedef struct {
  3. char name[10];
  4. int salary;
  5. }me;
  6. int main()
  7. {
  8. me a;
  9. a.name="ehab";
  10. a.salary=5789;
  11. printf("%s\n",a.name);
  12. printf("%d",a.salary);
  13. return 0;
  14. }
Jan 6 '11 #4
donbock
2,426 Expert 2GB
Look here for information about using CODE tags.

C doesn't allow you to simply assign a string to a character array. You have to copy the string into the array. Take a look at strcpy or strncpy.
Jan 6 '11 #5
yea thnx very much i remember it
thnx again
Jan 6 '11 #6

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

Similar topics

5
by: Sai Krishna M | last post by:
Lvalue Required......Why? Hello all, the following code is not compiling in Turbo C and the error is "Lvalue Required" . main() {
13
by: wessoo | last post by:
Hi All. What is The Lvalue Required error message. (What does it mean?Is it an abbreviationof something.) I wrote this test program and I am keeping geting this message. void main() {...
8
by: Rody Reulen | last post by:
I made an console application with Visual Basic .net. Visual Basic will automatically create the sub procedure main for you. I try to convert the main procedure to a function. During the...
1
by: joe10001 | last post by:
Hi all, I just installed CRELoaded (oscommerce fork) on my server and all work fine except that I have a little message at the bottom of the main page : Fatal error: main() : Security alert:...
7
by: Hexer | last post by:
Hi and good day to all...I am new to the C language and whenever I tried to run the program I made, it won't because it says it has an "expression syntax error in function main"..what I don't get is...
4
by: huggsy | last post by:
I started using C just today and I am having a problem with strrev() function. Here are my codes: #include<stdio.h> #include<conio.h> #include<string.h> main()
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...
2
by: ehab mohamed | last post by:
When i try to run this program it give me a message that Lvalue required in function main. What is the cause?
0
by: pecca | last post by:
this is sample of my program #include<iostream.h> #include<conio.h> #define n 5 int total(int number); int average(int average, int total); void min_max(int number,int &min,int &max); void...
1
by: DavidSS | last post by:
Okay, I have a problem. I just started programming, and made my first "calculator" I then started making it more advanced, so it wouldn't crash if you tried to divide by 0. Then I wanted to make...
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: 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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.