首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >C程序不工作:程序<path>与代码不存在

C程序不工作:程序<path>与代码不存在
EN

Stack Overflow用户
提问于 2022-07-10 21:16:16
回答 1查看 31关注 0票数 -1

长话短说,我正在用c ++ visual studio代码制作一个计算器,但当我调试它时,它会显示如下:在这里输入图像描述

我从来没有经历过这样的错误:

这是我的代码,如果有帮助的话:D

代码语言:javascript
复制
#include <stdio.h>

#include <stdlib.h>

void addition();

double division();

double subtraction();

void multiplication();



int main(){


    int opt_i;
    char opt_c;
    double opt_d;

    printf("\n\nWould you like to:");
    printf("\n1. Mutliply");
    printf("\n2.Divide");
    printf("\n3.Add");
    printf("\n4.Subtract");
    printf("\n(Choose a number)");
    scanf("%d",opt_i);

    if(opt_i==1){
        multiplication();
    }
    else if(opt_i==2){
        division();
    }
    else if(opt_i==3){
        addition();
    }
    else if(opt_i==4){
        subtraction();
    }
    else{
        printf("Invalid Option :(");
        sleep(3);
        printf("Wanna restart? [y,n]");
        printf("Your option: ");
        scanf("%c",opt_c);
        if(opt_c=='y'||opt_c=='Y'){
            int main();
        }
        else if(opt_c=='n'||opt_c=='N'){
            printf("Bye <:(");
            sleep(2);
            exit(0);
        }
        else{
            printf("Invalid Option again dude check your keyboard or smth :| :O 0_0 o_o -_-");
        }
        
    }
    void multiplication();{
        int ntp;
        int num1;
        int num2;
        int num3;
        int num4;
        int num5;
        int ans;
        

        printf("How many number would you like to multiply?(2-5) ");
        scanf("%d",ntp);
        if(ntp==2){
            printf("Enter a number to multiply: ");
            scanf("%d",&num1);
            printf("Enter the second number to multiply: ");
            scanf("%d",&num2);
            ans = num1*num2;
            printf("The answer is: %d\n",ans);

        }
        else if(ntp==3){
            printf("Enter a number to multiply: ");
            scanf("%d",&num1);
            printf("Enter the second number to multiply: ");
            scanf("%d",&num2);
            printf("Enter a third number to multiply: ");
            scanf("%d",&num3);
            ans = num1*num2*num3;
            printf("The answer is: %d\n",ans);

        }
        else if(ntp==4){
            printf("Enter a number to multiply: ");
            scanf("%d",&num1);
            printf("Enter the second number to multiply: ");
            scanf("%d",&num2);
            printf("Enter a third number to multiply: ");
            scanf("%d",&num3);
            printf("Enter a fourth number to multiply: ");
            scanf("%d",&num4);
            ans = num1*num2*num3*num4;
            printf("The answer is: %d\n",ans);
        }
        else if(ntp==5){
            printf("Enter a number to multiply: ");
            scanf("%d",&num1);
            printf("Enter the second number to multiply: ");
            scanf("%d",&num2);
            printf("Enter a third number to multiply: ");
            scanf("%d",&num3);
            printf("Enter a fourth number to multiply: ");
            scanf("%d",&num4);
            printf("Enter a fifth and final number to multiply: ");
            ans = num1*num2*num3*num4*num5;
            printf("The answer is: %d\n",ans);

        }
    }
       
       
        void addition();{
        int ntp;
        int num1;
        int num2;
        int num3;
        int num4;
        int num5;
        int ans;

        printf("How many number would you like to add?(2-5) ");
        scanf("%d",ntp);
        if(ntp==2){
            printf("Enter a number to add: ");
            scanf("%d",&num1);
            printf("Enter the second number to add: ");
            scanf("%d",&num2);
            ans = num1+num2;
            printf("The answer is: %d\n",ans);

        }
        else if(ntp==3){
            printf("Enter a number to add: ");
            scanf("%d",&num1);
            printf("Enter the second number to add: ");
            scanf("%d",&num2);
            printf("Enter a third number to add: ");
            scanf("%d",&num3);
            ans = num1+num2+num3;
            printf("The answer is: %d\n",ans);

        }
        else if(ntp==4){
            printf("Enter a number to add: ");
            scanf("%d",&num1);
            printf("Enter the second number to add: ");
            scanf("%d",&num2);
            printf("Enter a third number to add: ");
            scanf("%d",&num3);
            printf("Enter a fourth number to add: ");
            scanf("%d",&num4);
            ans = num1+num2+num3+num4;
            printf("The answer is: %d\n",ans);
        }
        else if(ntp==5){
            printf("Enter a number to add: ");
            scanf("%d",&num1);
            printf("Enter the second number to add: ");
            scanf("%d",&num2);
            printf("Enter a third number to add: ");
            scanf("%d",&num3);
            printf("Enter a fourth number to add: ");
            scanf("%d",&num4);
            printf("Enter a fifth and final number to add: ");
            ans = num1+num2+num3+num4+num5;
            printf("The answer is: %d\n",ans);

        }
    }
}

这里还有我的launch.json文件,因为当我收到错误时,它会提示我打开launch.json文件,如下所示

代码语言:javascript
复制
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "C/C++ Runner: Debug Session",
      "type": "cppdbg",
      "request": "launch",
      "args": [],
      "stopAtEntry": false,
      "externalConsole": false,
      "cwd": "c:/Users/ghazi/Desktop/calculator",
      "program": "c:/Users/ghazi/Desktop/calculator/build/Debug/outDebug",
      "MIMode": "gdb",
      "miDebuggerPath": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    }
  ]
}

请回答这个问题

EN

回答 1

Stack Overflow用户

发布于 2022-07-10 21:28:55

正如消息所述,您无法执行cal.exe,因为它不存在。

它不存在,因为当您试图构建它时发生了许多错误。其中一些可以在你的截图中看到。

一些错误来自于函数定义中多余的分号。例如,下面的分号不应该存在:

代码语言:javascript
复制
void multiplication();{
    ...
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72931956

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档