We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,324 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

warning!!!

warning: int format, pointer arg (arg 2)

i have no pointers this function :(

main..
functions....
functions.

int test(char num)
{
 int total[SIZE];

 printf("%d",total); fflush(stdout);              //no pointers

 return 0;
}
3
Contributors
3
Replies
8 Hours
Discussion Span
1 Year Ago
Last Updated
4
Views
Question
Answered
hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 8

Well, I assume this is a compiler warning. Post the rest of your code.

rubberman
Posting Maven
2,682 posts since Mar 2010
Reputation Points: 378
Solved Threads: 316
Skill Endorsements: 53
Question Answered as of 1 Year Ago by rubberman

ah i see the problem

hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 8

Since the OP found the problem but didn't explain what happened for readers of this thread, allow me:

int total[SIZE];
printf("%d",total);

The %d specifier expects an integer value, yet an unadorned total is equivalent to &total[0]. Thus the argument tied to %d is a pointer to int rather than an int, and the compiler is warning that it's probably not what the programmer wanted.

The total array was also not initialized, so trying to print any of it's elements is undefined behavior. Perhaps the OP wanted scanf() instead of printf(), but that's not a safe bet due to the use of fflush(stdout).

All in all, I'm not sure what the purpose of this function is, and that information is necessary to truly fix the problems.

deceptikon
Challenge Accepted
Administrator
3,499 posts since Jan 2012
Reputation Points: 822
Solved Threads: 481
Skill Endorsements: 58

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0693 seconds using 2.72MB