591 views
0 votes
0 votes
#include<stdio.h>
#include<stdlib.h>
int main()
{
    char s[] = "Opendays2012";
    int i = 0;
    while(*(s++))
    i++;
    printf("%d",i);
    return 0;
}

(a) Segmentation Fault (b) Compile Error (c) 12 (d) 0

1 Answer

Best answer
7 votes
7 votes

Answer will be B) Compile Error

In char s[size]; s is a constant pointer pointer. You can not perform operation like s++ or s = s + 1;

selected by

Related questions

0 votes
0 votes
1 answer
2
Desert_Warrior asked May 16, 2016
508 views
#include<stdio.h int a = 10; int main() { fun(); fun(); return 0; } int fun() { static int a = 1; printf("%d ",a); a++; return 0; }
0 votes
0 votes
0 answers
3
1 votes
1 votes
1 answer
4