我是一名C++学习者,我正在尝试编写一个基本的C++项目。这是基本的自动化系统。它具有一个导航菜单。

Choose an option :
   1 ) Add a new customer
   2 ) List all customers
   ...

将有一个nav变量,其中包含用户的选择。这是我的源代码:
#include <stdio.h>
#include <clocale>

int nav;

void main()
{
    setlocale(LC_ALL,"turkish");
    navigasyon();
    switch (nav) // checking 'nav' variable which assigned in navigasyon()
    case "1" :
         printf("Now you are adding a new customer");
    break;
    case "2" :
         printf("Now you are listing all customers");
    break;
}

void navigasyon()
{
    printf("Choose an option \n");
printf("1 ) Add a new customer\n");
printf("2 ) List all customers\n");

scanf("%d", &nav); // assigning '`nav' variable
}

很快,
在main()中,navigasyon()将显示导航菜单,用户选择1或2,然后navigasyon()将其关联到nav。最后用开关箱检查nav

但是我收到了'navigasyon': identifier not found错误。

最佳答案

您应该在navigasyon之前声明main

07-28 08:44