+ 1
Why does this give no output (in new to c and c++)
6 odpowiedzi
+ 2
printf("%d. %s",i,i);
the '%d' expect an int and you give it at parameter, but '%s' expect a string and you give it the same integer: either the mistake is in this second parameter type, either it's in the format parameter in the 'placeholder' ( pre-formatted ) string... As you don't have any string variable declaration in your code, try to change by:
printf("%d. %d",i,i);
+ 2
Yes, it should work too ;)
+ 2
Yep :P
You'll try to convert an integer between 0 and 128 to a single char: it couldn't work ^^
With %d ant the int it work... if you like to convert the second int to a char, try that:
printf("%d. %c",i,(char)(i+65));
You must change %s in %c, and add some count to your int, so the range isn't arround 0 ( first ascii char are non printable commands )...
+ 2
Changing %s to %c did it. It works now thanks...
+ 1
How about if I type cast the second integer to char.. It should print the char right?
+ 1
Did it.. Still no output... I'm not even sure if my program is faulty or just Sololearn is messing something up... It just says "no output"