Apr 12, 2010 at 3:52pm UTC
Hi,
Could anyone explain me following output in C.
#include<stdio.h>
int main()
{
char str[]="Zingle Bell Zingle Bell";
printf("%.#s %2s ,str ,str);
}
Apr 12, 2010 at 4:03pm UTC
That doesn't compile. There isn't output at all, other than the compiler error.
Apr 12, 2010 at 4:05pm UTC
he just forgot a second "
meant is:
1 2 3 4 5 6
#include <cstdio>
int main()
{
char str[]="Zingle Bell Zingle Bell" ;
printf("%.#s %2s" , str, str);
}
Last edited on Apr 12, 2010 at 4:05pm UTC
Apr 12, 2010 at 4:16pm UTC
It prints out a minimum of 2 characters of the character string, str. I don't see an immediate way of limiting the number of characters you want printed if that's what your looking for.
1 2 3 4 5 6
#include <cstdio>
int main()
{
char str[]="Zingle" ;
printf("%.#s %15s" , str, str);
}
This gives an example of what it does when minimum actually does something useful..
http://codepad.org/7sC6nAtg
Last edited on Apr 12, 2010 at 4:18pm UTC
Apr 13, 2010 at 4:42pm UTC
I could not understand the first string out. Why is it printing only first two character of the string
Apr 17, 2010 at 7:17pm UTC
Could anyone point me reason if it not wrong question.