Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have written a code and when i am compiling it i am getting an error as follow kindly help me to sort out this..


sosdt011@sosdt011:~/mysample$ gcc -o fir first.c
first.c: In function ‘main’:
first.c:14:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘char (*)[300]’ [-Wformat=]
fscanf(fp,"%s%s%s",&name,&city,&dept);
^
first.c:14:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘char (*)[300]’ [-Wformat=]
first.c:14:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘char (*)[300]’ [-Wformat=]
Posted
Comments
Bernhard Hiller 8-Oct-14 2:41am    
Why does that line
fscanf(fp,"%s%s%s",&name,&city,&dept);
remember me of question
http://www.codeproject.com/Questions/826441/How-to-read-data-and-modify-data-in-excel-in-unix?arn=184 ?
Are you also "Member 11134036"?

1 solution

You are adding the & (addresssof operator) to your array names, which is incorrect. Go and reread your C++ reference manual for the use of array names as pointers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900