C Programming - Pointers - Discussion
Discussion Forum : Pointers - Point Out Correct Statements (Q.No. 7)
7.
Which statement will you add to the following program to ensure that the program outputs "IndiaBIX" on execution?
#include<stdio.h>
int main()
{
char s[] = "IndiaBIX";
char t[25];
char *ps, *pt;
ps = s;
pt = t;
while(*ps)
*pt++ = *ps++;
/* Add a statement here */
printf("%s\n", t);
return 0;
}
Discussion:
14 comments Page 2 of 2.
Aishwarya said:
1 decade ago
Since pt is a character array the string is finally added a '\0'.
Pavan said:
1 decade ago
What is difference between pt='\0' and *pt='\0' ?
(1)
Sundar said:
1 decade ago
@Wikiok
Thanks for your explanation.
Thanks for your explanation.
Siri said:
7 years ago
Well said @Bandhan.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers