C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 14)
14.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char *str;
    str = "%d\n";
    str++;
    str++;
    printf(str-2, 300);
    return 0;
}
No output
30
3
300
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
43 comments Page 5 of 5.

RAJ KISHOR YADAV said:   1 decade ago
#include <stdio.h>
int main()
{

char *str="**********";

int i;
for(i=0;i<=3;i++)
printf("%*..*s\n",30,i,str);
return 0;

}

Hi guys,

Can any explain it?

Ram said:   1 decade ago
printf is right?

Abi said:   1 decade ago
Hi everyone!

Please explain, how come char ptr gives an integer as result without typecasting?


Post your comments here:

Your comments will be displayed after verification.