Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

#include <string.h>
#include <stdio.h>
int main()

{
char str1[20] = "Hello\0" ;
char str2[20] = "everyone\0" ;

printf("%i\n",strcmp(str1, str2) ;
printf("%i\n",strcmp(str2, str1) ;
printf("%i\n",strcmp(str1, str1) ;
}
 

 

i am getting an error with the printf lines and i cannot figure out what it is

Posted

you can't figure out what the error is ? For starters, your brackets don't line up. 

what I meant to say was, don't ask us to tell you how to fix an error, and not tell us the error message.  Also, \n is not a newline, \r\n is.  That won't break the code, but it will change the result.

Also, you don't return anything, so it still wouldn't compile after you fix the brackets.  Finally, if you meant C++ and not C, string.h is NOT part of C++. 

 
Share this answer
 
v3
Also, this is a repost: original
 
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