What is the error in this simple code:
#include <stdio.h>
int main()
{
char a[100];
int c;
int i = 0;
int x = 0;
while( ( c = getchar() ) != '\n' ) {
a[x++] =c;
}
a[x] = '\0';
while( ( a[i] != '\0' ) || ( a[i] != '.' ) ) {
printf( "\ni = %d", i );
i++;
}
return 0;
}
The second while loop does not stops and hence gives a segmentation fault
Compiler gcc 4.6.1
OS: Ubuntu 11.10