Jan 16, 2013 05:40 PM
(This post was last modified: Jan 16, 2013 06:02 PM by antigrav.)
EDIT: I'm a huge fucking dumbass. For those who might one day find this thread by search, let this serve as a lesson: apparently, you need to declare variables in the beginning of a code block. Example below.
Decided to get into a little C, being a native Python user. I literally just learned syntax today. Anyways, after typing some very basic code that SHOULD compile:
I'm getting errors. For some background, I'm using MSVC++2010 Express, and I've named the file main.c rather than main.cpp...
Here are the errors:
I've been Googling the errors, but they are usually not found in simple programs such as this, and honestly, after Googling, I still have NO idea why it isn't compiling.
Thoughts?
Code
#include <stdio.h>
int main()
{
int x = 0; //all I did was switch the first two lines
printf("I hate Hello World. So boring... \n"); //all you need to do is make sure variables are declared at the top
if(x==0){
printf("wat?");
}
getchar();
return 0;
}Decided to get into a little C, being a native Python user. I literally just learned syntax today. Anyways, after typing some very basic code that SHOULD compile:
Code
#include <stdio.h>
int main()
{
printf("I hate Hello World. So boring... \n");
int x = 0;
if(x==0){
printf(".-.");
}
getchar();
return 0;
}I'm getting errors. For some background, I'm using MSVC++2010 Express, and I've named the file main.c rather than main.cpp...
Here are the errors:
Code
1>c:\users\arnav\documents\visual studio 2010\projects\omfg\omfg\main.c(5): error C2143: syntax error : missing ';' before 'type'
1>c:\users\arnav\documents\visual studio 2010\projects\omfg\omfg\main.c(6): error C2065: 'x' : undeclared identifierI've been Googling the errors, but they are usually not found in simple programs such as this, and honestly, after Googling, I still have NO idea why it isn't compiling.
Thoughts?



