#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
system("PAUSE");
return 0;
}
After i Compiled the programme, i click run. it still tips me " project is not compiled" why? i am sorry, i am a new learner of c.
i am using dev c++, on xp, ctrl+F9 compile then ctrl+F10 run
it shows project is not compiled
multiple definition of main
Maybe in your project there is 2 Main function..
You should at least delete/change one..
if I see, there is 1-3.c and 1c.c
and the compile is error..
[Build Error]
CMIIW
Delete the file 1c.c. You cannot have two int main functions.
Related
Here's the code I wrote.
#include <stdlib.h>
#include <stdio.h>
int main(void){
printf("hello World.");
return 0;
}
This is the error message
Execution of '"C:\Users\Happy Birthday\Desktop\Coding\C++\C_C++ project\simple program.exe"' in 'C:\Users\Happy Birthday\Desktop\Coding\C++\C_C++ project' failed.|
I figured it out. I had to go to the location of the bin for MinGW, copy and paste its address into the Toolchain executables tab of the global compiler settings, as opposed to auto detecting it.
I have the following .c file:
/home/eamorr/project1/eamorr.c
I compiles fine and its exe is located at:
/home/eamorr/project1/a.out
Now, I have a php file at:
/home/eamorr/project1/a/b/c/eamorr.php
It needs to call a.out
<?php
$cmd=__DIR__."../../../a.out";
$result=`$cmd`;
?>
Here's the eamorr.c program:
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main (int argc, char *argv[]){
setuid (0);
char temp[2048];
char pwd[1024];
realpath(argv[0],pwd);
sprintf(temp,"/bin/bash %s/doMagic.sh",pwd);
system((char *)temp);
return 0;
}
Unfortunately the pwd variable contains the wrong path!!!
/home/eamorr/project1/a.out/doMagic.sh
How do I get rid of the a.out bit from the path? I don't program in C very often and I've been at this for over an hour now...
If I understand correctly, what you would like to get is something like:
/home/eamorr/project1/doMagic.sh
First of all, I dont generally do this kind of path handling in C. However, I had a quick look and it seems that you could use the dirname() functionality. Have a look here http://man7.org/linux/man-pages/man3/basename.3.html. Please be careful with this because I would imagine that these are Linux stuff, not sure how you would do it in DOS.
I am running the latest DevC++ 5.5.3 and I need to use the Allegro 5.0.4 so I downloaded it from devpaks and install it common way. But when I want to run the project with allegro the compiler show me error "allegro.h: No such file or directory". I was looking for the answer but I haven't found the relevant one. And what more I have to use DevC++.
#include <stdio.h>
#include <allegro.h>
int main(void)
{
allegro_init();
allegro_message("Hello World");
return 0;
}
END_OF_MAIN()
Linker is set to -lalleg
Allegro 5 is not backward compatible with Allegro 4. It is a brand new library made by the same people.
Your code snippet is for Allegro 4.
The equivalent is:
#include <allegro5/allegro.h>
#include <allegro5/allegro_native_dialog.h>
int main(void)
{
al_init();
// al_init_native_dialog_addon(); // Introduced in 5.0.9
al_show_native_message_box( /* fill in params */ );
return 0;
}
You would need to link against the main Allegro library along with the native dialogs library.
I am trying to learn C and I have just installed Xcode on my Mac. I wanted to run the first program that was already written
#include <stdio.h>
int main(int argc, const char * argv[])
{
// insert code here...
printf("Hello, World!\n");
return 0;
}
and got build failed.
I created a program in C. The libraries have been downloaded.
Thanks
Are you trying to learn C or Objective-C? As far as I know, XCode is only appropriate for Objective C.
Also, can you post your compiler error, that will help alot.
I have recently started learning C as a side project. I am working under OpenSuse with the latest NetBeans using the GCC as toolset for compiling.
One of the very first programs that I made was this:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*
*
*/
int main(int argc, char** argv) {
double rad = 1;
double result = 0;
result = sin(rad);
return (EXIT_SUCCESS);
}
This is a simple, no-brainer example that should have worked without a problem. However, I get a Build Error: Exit code 2(error in line 18, undefined reference to sin) when trying to compile.
Interestingly enough, if I remove the assignment of the value of sin(rad) to result OR replace rad with a hard coded value, the program compiles just fine.
What am I doing wrong here?
In C, you need to link to the math library:
Add this to the command line options:
-lm
Be sure that your are linking with the math library.
$ gcc myprog.c -lm