im linux user!!!!
how to run this script?

int main(void)
{
printf("Hello world!\n");
return 0;
}

its written with emacs
what to do?
is there any programming tool in linux for C programming?

Recommended Answers

All 18 Replies

more than likely you will be using the common gcc compiler. Here is a short tutorial to get you going.

you should also read the sticky threads at the beginning of this board, including this one which contains lots of links to other programming articles and tutorials.

thanks a lot for the first tutorial

is possible to run this scripts in programs like Kdevelop c c++ or anjuta?

I don't know anything about them so I can't answer that question. Most people, including me, just creat a console window and run the scripts from command prompt as shown in that tutorial.

Maybe you are a bit confused between Programming and Scripting languages, though the demarkation is a bit fuzzy but Scripting langs are meant to be simplify the task of the programmer and carry out repetitive tasks in an automated and easy manner. They have inbuilt automatic garbage collector. They are mostly interpreted languges (no object file is formed). Some egs are the famous Perl, PHP, Python etc.

C, C++, JAVA are programming languages in the way that they require a compilation phase before the execution phase.

The program which you have written in your first post can easily be compiled and run on any of the compilers present in the link given to you by Mr. Ancient Dragon. So download the compiler and IDE and try running the code. If you still face problems then repost.

Hope it helped, bye.

you probably forgot to include stdio.h. Add this as the first line of your program

#include <stdio.h>
// rest of your program goes here

thanks but still get this err
jan@jan-desktop:~$ gcc firstc.i
firstc.i:1: error: stray ‘#’ in program
firstc.i:1: error: syntax error before ‘<’ token
jan@jan-desktop:~$

if i rename file to firstc.c it happens nothin

please help

you need to repost your program because I can't see it from where I am sitting.

Type the code exactly as i am typing and then try to run it

#include <stdio.h>

int main (void)
{
    printf ("\nHello to you newcomer") ;
    getchar () ;
    return 0 ;
}

Repost if you get any errors.

#include <stdio.h>
int main(void)
{
printf("Hello world!\n");
return 0;
}

can you eplain me all...please

vhen running your file it happens nothing
an@jan-desktop:~$ gcc rep.c
jan@jan-desktop:~$ gcc rep.c
jan@jan-desktop:~$ gcc rep.c
jan@jan-desktop:~$

gcc only compiles your program into an executable file, it does not run your program. The default name of your program is a.out because you did not tell gcc what to name it. So to run your program, try this:

./a.out <Enter key>

jan@jan-desktop:~$ ./a.out <Enter key>
bash: syntax error near unexpected token `newline'

Use ls command to search the directory and see if it contains a file called a.out. If not, then gcc probably did not compile it. If it didn't then compare your program with what ~S.O.S.~ posted and make sure it is identical. And from here I think you need to start reading some of the links that were posted in the sticky at the top of this board. I know its a lot of reading, but if you want to learn how to program you must also be willing to do a lot of reading and studying.

Its good that you are going to buy a book, that's the best way to learn. But that book won't teach you a thing about gcc compiler or how to use linux. you need to learn how to compile and execute a program before that book (or most any other book for that matter) will be much help to you.

oh actualy i have another book with chapter programming tools which is including all that .....

so what with that file...im not able to open it

jan@jan-desktop:~$ ./a.out <Enter key>
bash: syntax error near unexpected token `newline'

I did not mean for you to type "<Enter key>" on the command line -- that only meant that you should have hit the Enter key on the keyboard. If you actually typed that text, then try it again without that part. just

$ ./a.out

thanks but i discovered that by myself....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.