c - making a program to add a list of names in 2d array actually I just made a part of it and I have alot of errors -


my code :


#include <stdio.h> #include <stdlib.h> #include <string.h>  int main(void) {     char names[10][31];     int u=0;     char new[31];     int ctr=1;     int notinlist=0;     int y=0;     int i=0;     char *p;      strcpy(names[0],"mahmoud");      while(1)     {         printf("\t\t§§§menu items§§§\n");         printf("1==>enter new name\n");         printf("2==>search name\n");         printf("3==>delete name list\n");         printf("note !!.. ((if want exit program press(1)and  type ((exit))\n");         fflush(stdin);         scanf("%i",&u);         notinlist=1;         if(u==1)         {             printf("please enter name : ");             fflush(stdin);             gets(new);             _strlwr(new);             if(strcmp(new,"exit")==0)              {                 printf("bye bye\n");                 break;             }             else             {                 notinlist=1;                 for(int i=0;i<=ctr;i++)                 {                      p=strstr(new,names[i]);                     if(strcmp(new,names[i])==0)                     {                         printf("the name exist\n");                         break;                     }                     else if (p)                     {                         printf("did mean (( %s ))\n",names[i]);                         printf("1==>yes\n");                         printf("2==>no\n");                         fflush(stdin);                         scanf("%d",&y);                         if(y==1)                         {                             printf("the name exist\n");                             break;                         }                         else if(y==2)                         {                             notinlist=0;                             strcpy(new,names[ctr]);                             ctr++;                             break;                         }                         else printf("plz enter number list");                     }                     else                      {                         notinlist=0;                     }                 }                     if(notinlist==0)                     {                         strcpy(new,names[ctr]);                         ctr++;                         for(int i=0;i<ctr;i++);                         {                             printf("%d==>%s\n",i+1,names[i]);                         }                     }                 //  break;             }         }         return 0;     } 

the first problem : when enter ( 1) , add name similar first name printf me did mean ( )//// without name


the second when want add new name doesn't please me


notice program not finished first choise


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -