[cs631apue] non-homework: welcome.c

cpunjabi cpunjabi at stevens.edu
Sun Sep 14 11:28:39 EDT 2014


When I tried to compile Welcome.c program, I got one warning and one 
Error message:

welcome.c:5:2: warning: format '%s' expects argument of type 'char *', 
but argument 2 has type 'int' [-Wformat]
welcome.c:6:1: error: expected ';' before '}' token

1.Warning message explains that the argument we are passing in printf 
function expects the char * (char pointer i.e array of char) but 
getlogin() function returns the decimal/integer value. We can solve this 
warning by using %d or %i in printf function instead of %s.

2. Error explains that ';' is missing before '}' character. This can be 
solved by inserting ';' at the end of printf function.

Thanks,
Chirag Punjabi


On 2014-09-14 08:03, sshah83 wrote:
> On 09/12/2014 9:47 PM, Jan Schaumann wrote:
>> Hello,
>> 
>> Remember the welcome.c program you tried to run in our first class?  
>> If
>> you didn't get it to run (and run as expected), revisiting that would 
>> be
>> a good exercise.  Can you explain why/how it fails, and what the
>> compiler error or warning messages mean?  How did you resolve the
>> problem?
>> 
>> -Jan
>> _______________________________________________
>> cs631apue mailing list
>> cs631apue at lists.stevens.edu
>> https://lists.stevens.edu/mailman/listinfo/cs631apue
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue


More information about the cs631apue mailing list