execute a programm
hi dear's,
how and where i can execute below code?? int main() { system("ls"); return 0; } thanks |
This is a little C program that does a system call to execute the ls command (pretty not useful, since you can do ls directly from the shell). Anyway, you have to write the code in a text file and then compile it using gcc. Run the resulting executable (a.out by default) and you will get a list of the files in the current working directory.
|
i run nano main.c and write below code:
#include<stdio.h> #include<stdlib.h> int main() { printf("\nHello World,\nWelcome to my first C program in Ubuntu Linux\n\n"); return(0); } when i run above programm,system show below error ,why?? root@goldengriff:/home/goldengriff/CCPP/HelloWorld# ./main.c.save ./main.c.save: line 1: syntax error near unexpected token `newline' ./main.c.save: line 1: `#include<stdio.h> ' |
Before running, you have to compile it!!!!!!
Type: Code:
gcc main.c -o main Code:
|
when i compile code,below error showed:
test.c:1:21: fatal error: iostream.h: No such file or directory compilation terminated. |
Post the code
|
#include<iostream>
main() { cout<<"hello"; return(0); } |
Here's the right code:
Code:
Code:
Code:
|
All times are GMT -5. The time now is 07:58 AM. |