Как запустить программу C в Visual Studio (Ma c) - PullRequest
0 голосов
/ 19 января 2020

, поэтому я пытаюсь запустить программу C в первый раз, используя VS и Ma c ОС Catalina, однако я получаю следующие сообщения об ошибках при попытке запустить:

#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)

I ' Я использую расширение Code Runner в VS для запуска кода C, и я также установил следующие вещи, используя homebrew:

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;
}

1 Ответ

0 голосов
/ 19 января 2020

Перед попыткой компиляции необходимо установить среду C (включая заголовочные файлы, библиотеки и т. Д. 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/
...