C Programming - Strings - Discussion
Discussion Forum : Strings - Find Output of Program (Q.No. 31)
31.
What will be the output of the program in Turbo C?
#include<stdio.h>
int main()
{
char str[10] = "India";
str[6] = "BIX";
printf("%s\n", str);
return 0;
}
Answer: Option
Explanation:
str[6] = "BIX"; - Nonportable pointer conversion.
Discussion:
16 comments Page 2 of 2.
Swathi said:
1 decade ago
Can any one explain non-portable conversion ?
Avinash said:
1 decade ago
What is nonportable converter?
George said:
1 decade ago
Hello,
The code in Linux works find and gives "India" as the answer. The reason is this: in the declaration :
char str[10]="India";
// the stringlength is 5 so the
// the string terminator will be at str[5]
// any operation after str[5] will be not
// valid.
The code in Linux works find and gives "India" as the answer. The reason is this: in the declaration :
char str[10]="India";
// the stringlength is 5 so the
// the string terminator will be at str[5]
// any operation after str[5] will be not
// valid.
Pavani said:
1 decade ago
What is nonportable pointers?
Mani said:
1 decade ago
When i execute this in gcc compiler it gives the o/p as India.
Vishal modi said:
1 decade ago
Nonportable pointer conversion means. ?
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers