C Programming - Strings - Discussion
Discussion Forum : Strings - Find Output of Program (Q.No. 19)
19.
What will be the output of the program ?
#include<stdio.h>
int main()
{
char str1[] = "Hello";
char str2[10];
char *t, *s;
s = str1;
t = str2;
while(*t=*s)
*t++ = *s++;
printf("%s\n", str2);
return 0;
}
Discussion:
22 comments Page 3 of 3.
Wikiok said:
1 decade ago
If s[n] == '\0' then ( *t=*s ) == zero, so it is false, so the loop will exit.
Nikhil said:
1 decade ago
In the loop, it is always a true condition hence it will never come out of the loop so no output
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers