C 制作一个在2d数组中添加名字列表的程序实际上我只是制作了其中的一部分,我有很多错误

C 制作一个在2d数组中添加名字列表的程序实际上我只是制作了其中的一部分,我有很多错误,c,if-statement,for-loop,multidimensional-array,while-loop,C,If Statement,For Loop,Multidimensional Array,While Loop,我的代码是: #包括 #包括 #包括 内部主(空) { 字符名称[10][31]; int u=0; char-new[31]; int ctr=1; int notInList=0; int y=0; int i=0; char*p; strcpy(名称[0],“mahmoud”); 而(1) { printf(“\t\t§§菜单项§§\n”); printf(“1==>输入新名称\n”); printf(“2==>搜索名称\n”); printf(“3==>从列表中删除名称\n”); pr

我的代码是:


#包括
#包括
#包括
内部主(空)
{
字符名称[10][31];
int u=0;
char-new[31];
int ctr=1;
int notInList=0;
int y=0;
int i=0;
char*p;
strcpy(名称[0],“mahmoud”);
而(1)
{
printf(“\t\t§§菜单项§§\n”);
printf(“1==>输入新名称\n”);
printf(“2==>搜索名称\n”);
printf(“3==>从列表中删除名称\n”);
printf(“注意!!…(如果要退出程序,请按(1),然后键入((退出))\n”);
fflush(stdin);
scanf(“%i”和“&u”);
notInList=1;
如果(u==1)
{
printf(“请输入名称:”);
fflush(stdin);
获取(新的);
_strlwr(新);
如果(strcmp(新,“退出”)==0)
{
printf(“再见”\n);
打破
}
其他的
{
notInList=1;

for(int i=0;i
for(int i=0;它的
gets()
函数已贬值多年,在最新的C标准中不存在。强烈建议将对
gets()
的任何调用替换为对
fgets()
的调用(该函数具有不同的参数集。发布的代码缺少右括号)}’。我不太确定它需要添加到哪里,以便于我们人类阅读和理解:1)用一个空行分隔代码块(for、if、else、while、do…while、switch、case、default)。2)在每个左大括号之后缩进代码(建议使用4个空格,从不使用制表符){‘在每个右大括号之前取消缩进代码’}'什么//函数在哪里:
\u strlwr()
1)它不在C库中。2)请注意,以双下划线或下划线和大写字母开头的符号是无条件保留给实现的。是的,系统头使用带有双下划线的名称-它们是实现的一部分,不允许污染名称空间。您不应该污染它们的名称空间。出于所有实际目的d尽管有多个反例,但应将以下划线开头的名称视为保留用于实现的名称。
#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 a new name\n");
        printf("2==>search for a name\n");
        printf("3==>delete a name from the list\n");
        printf("Note !!.. ((if you want to exit the program press(1)and  then type ((exit))\n");
        fflush(stdin);
        scanf("%i",&u);
        notInList=1;
        if(u==1)
        {
            printf("please enter a 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 is already exist\n");
                        break;
                    }
                    else if (p)
                    {
                        printf("did you mean (( %s ))\n",names[i]);
                        printf("1==>yes\n");
                        printf("2==>no\n");
                        fflush(stdin);
                        scanf("%d",&y);
                        if(y==1)
                        {
                            printf("the name is already exist\n");
                            break;
                        }
                        else if(y==2)
                        {
                            notInList=0;
                            strcpy(new,names[ctr]);
                            ctr++;
                            break;
                        }
                        else printf("plz enter a number from the 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;
    }