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();
}

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

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..

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.