Linux script running c program

Asked
Active3 hr before
Viewed126 times

3 Answers

running
90%

Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers ,i tried to run a script in linux to run a c program the script was as follows,but the problem is that when i run this script the all the scanf statement are executed then all the outputs are shown simentaniously....,Putting echo returns a blank line on the display screen followed by the command prompt on the subsequent line. This is because pressing the ENTER key is a signal to the system to start a new line, and thus echo repeats this signal.

Get rid of the backticks, the chmod, and the echo. All you need to do is run gcc, then run your program.

#!/bin/bash

gcc odd.c - o odd222
   . / odd222

It'd also be good to only try to run the program if it compiles successfully. You can make it conditional by using &&.

#!/bin/bash

gcc odd.c - o odd222 && . / odd222

It'd also be good to modify your C code to ensure the printouts are printed immediately. Output is usually line buffered, meaning it's only displayed once you write a full line with a newline \n at the end. You'll want to either print a newline:

printf("enter the no.\n");

Or flush the output explicitly:

printf("enter the no.");
fflush(stdout);
load more v
88%

#!/bin/bash

gcc - o program program.c
   . / program
load more v
72%

We will be using the Linux command-line tool, the Terminal, in order to compile a simple C program. To open the Terminal, you can use the Ubuntu Dash or the Ctrl+Alt+T shortcut.,In order to compile and execute a C program, you need to have the essential packages installed on your system. Enter the following command as root in your Linux Terminal:,In your Terminal, enter the following command in order to make an executable version of the program you have written:Advertisement,Through this article, you have learned how to write, compile and run a simple C program in Linux. All you need is the essential packages and the right skills to make you a programming guru in Linux!

In order to compile and execute a C program, you need to have the essential packages installed on your system. Enter the following command as root in your Linux Terminal:

$ sudo apt - get install build - essential
load more v

Other "running-undefined" queries related to "Linux script running c program"