0

hi any one help me..

in this pgm if i use pointer in name means it correctly working, but by using array to name it doesnt work properly... it shows lvalue required.. by using array i need to run this pgm....

plz help me...


main()
{
type def struct
{
char name[66]l
int no;
}re;
re can[2];
int a;
can[0].name="xx";
can[1].name="yy";
for(a=0;a<=1;a++)
{
printf("enter no");
scanf("%d",&can[a].no);
}
for(a=0;a<=1;a++)
{
printf("candidate code=%d\tcandidate name=%s\n",can[a].no,can[a].name);
}
getch();
}

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by zeroliken
0

After "char name[66]", you need a semi-colon ;
...not a pipe ¦

ya sorry that is spell mistake....
but i ve given ; only in my pgm..

0
typedef struct{ //there is no space in typedef
     char name[66]l
     int no;
}re;

main(){  //I suggest you use int main 
//rest of your code here

}

Don't declare the structure inside the main function declare it outside and above from the main

can[0].name="xx";
can[1].name="yy";

you cannot simply assign one array to another. You have to copy it element by element.
use strcpy() for assigning a value "If your not familiar with it you can search google"

Don't forget to include this header

#include<string.h>

Edited by zeroliken: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.