#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ FILE * fp1 = fopen("file.csv", "r"); char string[200], toFind[200], savedLine[200], option; char* lineOne = NULL; char* result = NULL; printf("Enter your ID Card number: "); scanf("%s", toFind); while(fgets(string, 200, fp1)){ lineOne = strtok(string, "\n"); strcpy(savedLine, lineOne); result = strstr(savedLine, toFind); if(!result){ printf("Are you sure? [y/n]: "); while ((getchar()) != '\n'); scanf("%c", &option); if(option == 'y'){ printf("%s\n", lineOne); printf("Your account is removed\n"); } if(option == 'n'){ printf("Your account is not removed.\n"); break; } } } fclose(fp1); return 0; }
break
... while ((option = getchar()) != 'y' && option != 'n'); if(option == 'y') { ...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)