I wrote a code regarding string input and finding vowels in the string. Everything works fine except the program doesn't exit the do while loop.
do{
i = 0; j = 1;
str = NULL;
input = '\0';
for(l = 0; l < 5; l++ ) { /* initializing arrays with zeros */
lowercase_vowel[l] = 0;
uppercase_vowel[l] = 0;
}
str = (char*)malloc(sizeof(char)); /* allocating space for a character in str */
printf("\nEnter String : ");
while(input != '\n' ) /* until user press enter */
{
input = getc(stdin); /* taking the input */
str = (char*)realloc(str,j*sizeof(char)); /* re-allocate memory for character read to be stored */
str[i] = input; /* store read character */
i++;
j++;
}
str[i]='\0'; /* appending null character to the string */
/*Some calculations here */
printf("\nDo you want to continure? (Y / N)");
scanf("%c", &option);
}while( (option != 'N') || (option != 'n') );
The problem is that the loop doesn't end when I give the options and also it skips the part
printf("\nEnter String : ");
and just calculates according to the value in option. I would really appreciate if someone helped me in this problem