Output in Printf

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);

}
closed account (S6k9GNh0)
That doesn't compile. There isn't output at all, other than the compiler error.
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
closed account (S6k9GNh0)
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
I could not understand the first string out. Why is it printing only first two character of the string
Could anyone point me reason if it not wrong question.
Topic archived. No new replies allowed.