We have to prepare a presentation in "Structured Programming" (Ansi C) about the usage of C in Visual Studio. I already found out how to make a C file and use the C++ compiler to run it, but there are still some questions left where i didn't found a awnser yet.
For example:
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main(void){
srand((unsigned int)time(NULL)); //seed for random number..
unsigned int ran = rand();
printf("Helloooo World");
printf("%u",ran);
getchar();
return 0;
}
On Linux with vim it worked. But with Visual Studio I get the errors: http://www.pic-upload.de/view-25860939/Capture.jpg.html
I think it is because of my included functions, and now my question is what functions Visual Studio owns for C, or what I have to change to make my program run in Visual Studio?
I would be really glad to read some answers. And i hope that i didn't was just to stupid to find the answers here.. :'D
Try:
include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main(void){
unsigned int ran;//<--- Declare ran here.
srand((unsigned int)time(NULL)); //seed for random number..
ran = rand(); ////<--- Use ran here (as before).
printf("Helloooo World");
printf("%u",ran);
getchar();
return 0;
}
Visual Studio 2012 doesn't yet support C99. I mean it's only 12 years prior!!!
You have to declare your variables at the start of functions when compiling C.
I know! Shish!