i have written one programm in c using structure to enter name and account number of the emplpyee.the programm shows an error which is
filename.c:11 error:expected identifier or "("before"["token..i am not able to get the error...please clearify it.

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
 main()
{
	struct wipro
	{
		char name[20];
		char accnum[10];
	};
	struct wipro_employee[5]
	    {
		 int i;
		char j[8];
		for (i = 0;i < 5;i++)
		{
			printf("enter the name of employee");
			gets("employee[i].name");
			printf("%accnum");
			gets("j");
			employee[i].accnum = atoi(j);
		}
		for (i = 0;i < 5;i++)
		{
			printf("the name of the employee is %s\n", employee[i].name);
			printf("his age is %d\n", employee[i].accnum);
			getch();
		}
	}
	}

A structure is a collection of one or more variable , possibly of different types,grouped together under a single name for convenient handling.

For the first time,I am seeing such a use of structure..
Can you please explain me your code.

possibly what I understand is, you are trying to do this:-

#include<stdio.h>
#include<stdlib.h>
 struct wipro
{
		char name[20];
		int accnum;
};
 main()
{
	struct wipro employee[5];
		 int i;
		char j[8];
		for (i = 0;i < 5;i++)
		{
			printf("enter the name of employee");
			scanf("%s",employee[i].name);
			printf("accnum:-");
			scanf("%s",j);
			employee[i].accnum = atoi(j);
		}
		for (i = 0;i < 5;i++)
		{
			printf("the name of the employee is %s\n", employee[i].name);
			printf("his accno is %d\n", employee[i].accnum);
		}
}

Edited 5 Years Ago by cse.avinash: n/a

ohh yep..
I should ve written int main() instead..and should have included return 0;
I ll keep this is my mind from the next time..

thanks for replying .yeah i want to do that what u stated but .i cant to use gets().
i will keep in my mind your syntax.thanks but let me know the way to use get in this syntax

thanks for replying .
yeah i want to do that only what you stated through your code .but i want to use gets()function to input data..suggest me the possible syntsax.and what does the error that i have stated mean.

here's the syntax:

char * gets ( char * str );

Don't wrap the parameter with inverted commas.

Btw, if you googl'ed for the syntax, you would've got it in seconds!

Anyway, now that you know about gets(...), know it's pitfalls too...read this

Consider using fgets(...) as suggested.

Edited 5 Years Ago by NP-complete: n/a

thanks avinash..i tried ur code but scanf is not working in it ..when i m using gets it is showing the output.
but it is taking 5 respective input that i m giving..and finally it is showing the following
suppose when i enter 5 names and 5 accnum
amit
758768
gaurav
9789689
sanjay
868969857
ashish
8689698
avinash
79868958
it is showing as
the employee name is5786896
his accnum is686862.
the data is not exact..i just tried to explain.please figure out what is the problem behind the programm

This article has been dead for over six months. Start a new discussion instead.