Monday, August 17, 2009

c++: string literal: char *a = "hello "; strcat(a, b);

main()
{
char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcat(a,b));
}
A) HelloWorld
B) Hello World
C) Hello
D) None of the above



It will give a sementation fault
The pointer a is allocated just sufficient space to accomodate "Hello". When we add beyond that it will give a seg fault

No comments:

Post a Comment