C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 7)
7.
What will be the output of the program ?
#include<stdio.h>
int main()
{
char *str;
str = "%s";
printf(str, "K\n");
return 0;
}
Discussion:
58 comments Page 3 of 6.
Bhavin said:
1 decade ago
What we write in double quotes will get printed simple?
Nithiya said:
1 decade ago
int main()
{
int *str;
str = "%d";
printf(str, "5\n");
return 0;
}
What will be the output?
{
int *str;
str = "%d";
printf(str, "5\n");
return 0;
}
What will be the output?
Shahin said:
1 decade ago
So, can we assign a format specifier to the variable ? If so, the above solution will be correct explain me?
Shahin said:
1 decade ago
@Nithiya.
The output will be garbage value.
The output will be garbage value.
Armaan said:
1 decade ago
Kavyashree is just correct
Satyam said:
9 years ago
Thanks to everyone. Really useful discussion.
Zdd said:
8 years ago
Thank you @Hann.
Sudheer said:
8 years ago
Thank you @Sandeep.
Prakash said:
1 year ago
There is no format specifier in print statement. So it doesn't print the structure value it only prints the K.
Pranay Pradhan said:
2 months ago
@all.
We get an equivalent output from the following:
#include<stdio.h>
int main()
{
char str[3] = "%s";
printf(str, "K\n");
return 0;
}
We get an equivalent output from the following:
#include<stdio.h>
int main()
{
char str[3] = "%s";
printf(str, "K\n");
return 0;
}
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers