Is Visual Studio Compatible with ANSI C Standards?

In summary: I am starting a programing class for scientists and engineers at the end of the month. I wanted to brush up on my C. I used to compile C programs with Visual Studio, but now that no longer seems to work. Even simple example programs in the book generate a litiney of compile errors in Visual Studio (using the Win32 console type application)For example:#include <stdio.h>int main(){printf("Goodbye, cruel world!\n");return(0);}generates the following compile errors:Error 1 error C2065: '"Goodbye' : undeclared identifier c:\documents and
  • #1
vociferous
253
6
I am starting a programing class for scientists and engineers at the end of the month. I wanted to brush up on my C. I used to compile C programs with Visual Studio, but now that no longer seems to work. Even simple example programs in the book generate a litiney of compile errors in Visual Studio (using the Win32 console type application)

For example:

#include <stdio.h>
int main()
{
printf("Goodbye, cruel world!\n");
return(0);
}
generates the following compile errors:

Error 1 error C2065: '"Goodbye' : undeclared identifier c:\documents and settings\administrator.minerva.000\my documents\visual studio 2005\projects\goodby world\goodby world\goodby world.cpp 11
Error 2 error C2065: 'cruel' : undeclared identifier c:\documents and settings\administrator.minerva.000\my documents\visual studio 2005\projects\goodby world\goodby world\goodby world.cpp 11
Error 3 error C2146: syntax error : missing ')' before identifier 'world' c:\documents and settings\administrator.minerva.000\my documents\visual studio 2005\projects\goodby world\goodby world\goodby world.cpp 11
Error 4 error C2017: illegal escape sequence c:\documents and settings\administrator.minerva.000\my documents\visual studio 2005\projects\goodby world\goodby world\goodby world.cpp 11
Error 5 error C2059: syntax error : ')' c:\documents and settings\administrator.minerva.000\my documents\visual studio 2005\projects\goodby world\goodby world\goodby world.cpp 11

Now, I thought that C was supposed to be an ANSI standard and that all C++ compilers were supposed to be able to handle it. Does Visual C++ not conform to that standard or am I just doing something wrong?
 
Technology news on Phys.org
  • #2
Can you post the entire output of the compiler? Are you sure you're running, say, the C++ compiler, and not the C# compiler?

- Warren
 
  • #3
I was using visual c++ as a console application and it was generating those errors a couple of days ago. I tried the code on several different projects (regular win32 and win32 consoles) and it refused to compile. When I tried making a new project just a few minutes ago, it compiled and ran perfectly fine. Then I reopened the project that did not compile and it compiled without errors or warnings as well. As far as I know, I did not do anything different, but apparently it is working now. Maybe it was a bug in visual studio, and rebooting fixed it.

Anyway, thanks for your help; I wish I knew what caused the error, but as long as it works now it is of no great concern.
 
  • #4
TRY adding "int main(int argc, char*argv[])",i believe that's required for empty project. visual studios is kinda picky about certain things...Also make sure you ran a "Win32 console Empty project". If yiour using your own computer try making a shorter directory paths...eg. "C\Code\Projects"
 
Last edited:
  • #5
After selecting new project, Win32 console, and entering the name, click on application settings, and then click on "empty project".
 
  • #6
I figured out what the problem was, and it made me feel somewhat stupid. I tried posting examples from a text I was using, and I just cut-and-paste the text into the editor. The compiler did not like the fancy publishing quotation marks.
 
  • #7
hahahhahahhaha
 
  • #8

1. What is C code?

C code is a programming language used to write computer programs. It was developed in the early 1970s and is commonly used for system programming, such as operating systems, device drivers, and application software.

2. What is Visual Studio?

Visual Studio is an Integrated Development Environment (IDE) created by Microsoft. It provides developers with a comprehensive set of tools for developing software, including C code, and allows for debugging, testing, and deploying applications.

3. Can C code be written in Visual Studio?

Yes, C code can be written in Visual Studio. Visual Studio offers a variety of project templates for C code and has built-in features for editing, compiling, and debugging C code.

4. How do I compile C code in Visual Studio?

To compile C code in Visual Studio, you first need to create a new C project or open an existing one. Then, click on the "Build" menu and select "Build Solution." This will compile your code and generate an executable file that can be run on your computer.

5. Can I use Visual Studio for C code on different operating systems?

Yes and no. Visual Studio itself only runs on Windows operating systems. However, you can use Visual Studio to develop C code for different operating systems by using cross-platform development tools, such as the Visual Studio Code editor, which is available for Mac and Linux.

Similar threads

  • Programming and Computer Science
Replies
0
Views
204
  • Programming and Computer Science
Replies
2
Views
265
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
25
Views
14K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
16
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
Back
Top