簡體   English   中英

如何在 Visual Studio (Mac) 中運行 C 程序

[英]How to run C program in Visual Studio (Mac)

所以我第一次嘗試使用 VS 和 Mac OS Catalina 運行 C 程序,但是在嘗試運行時我收到以下錯誤消息:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/xxx/Documents/EECS2031/scanf2.c).C/C++(1696)


cannot open source file "stdio.h"C/C++(1696)

我在 VS 中使用“Code Runner”擴展來運行 C 代碼,我還使用自制軟件安裝了以下內容:

xcode-select --install
brew install gcc

我不知道還能做什么,因為我是 C 的新手,搜索后還沒有找到任何其他解決方案,所以我需要一些幫助。 如果有幫助,c 文件名也有一個 .c 擴展名。

這是C代碼:

#include <stdio.h>
/*The error is here when I am trying to include this library*/


int sum (int i, int j)
{
  return i+j;           
}


main()
{
  int a, b;
  printf("Please enter two integers separated by a blank: " );

  scanf( "%d %d",  &a, &b);     /* assign value to a b  */

  printf("Entered %d and %d. Sum is %d\n", a, b, sum(a,b));

  return 0;
}

在嘗試編譯之前,必須安裝 C 環境(所有包含頭文件、庫等)。

這個網頁應該對你有很大幫助:

https://www.tutorialspoint.com/cprogramming/c_environment_setup.htm

尤其是這一段:

Installation on Mac OS

If you use Mac OS X, the easiest way to obtain GCC is to download the Xcode development environment from Apple's web site and follow the simple installation instructions. 
Once you have Xcode setup, you will be able to use GNU compiler for C/C++.

Xcode is currently available at 

developer.apple.com/technologies/tools/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM