-c stand for cmd which allows you to pass your code as a string. This feature is available even outside of google-cloud-platform. you can check other available options using python -h
Answer from Ilyes KAANICH on Stack Overflow-c stand for cmd which allows you to pass your code as a string. This feature is available even outside of google-cloud-platform. you can check other available options using python -h
the -c flag means execute the following command as interpreted by this program.
Doc: https://askubuntu.com/questions/831847/what-is-the-sh-c-command
Videos
As the system() call uses a shell to execute the command, you can redirect stdout and stderr to /dev/null, e.g.
system("ls -lh >/dev/null 2>&1");
popen is another way in which you can do the same:
void get_popen() {
FILE *pf;
char command[20];
char data[512];
// Execute a process listing
sprintf(command, "ps aux wwwf");
// Setup our pipe for reading and execute our command.
pf = popen(command,"r");
// Error handling
// Get the data from the process execution
fgets(data, 512 , pf);
// the data is now in 'data'
if (pclose(pf) != 0)
fprintf(stderr," Error: Failed to close command stream \n");
return;
}
It does not actually insert the character sequence "^C". This is only a representation for unprintable ASCII control characters, such as:
^C→ ETX (End of text, sends a kill signal), ASCII 0x03^D→ EOT (End of transmission, terminates input), ASCII 0x04^H→ BS (Backspace,\b), ASCII 0x08^J→ LF (Line feed,\n), ASCII 0x0A^L→ FF (Form feed, new page, clears the terminal), ASCII 0x0C^M→ CR (Carriage return,\r), ASCII 0x0D
This is only a small extract of possible ASCII control characters that can be inserted using the keyboard; you can find a full list here.
I think the most important ones to remember are Ctrl+C, Ctrl+D and Ctrl+L.
Because CTRL+KEY combos are interpreted by the terminal as non-printable ASCII characters, and being those non-printable you need a way to represent them.
The convention, stemming from VT terminals with ANSI support, is to represent the CTRL+KEY combo representing CTRL with a caret (^) and KEY with KEY.
The \c keeps the cursor on the same line after the end of the echo, but to enable it, you need the -e flag:
echo -e "bla bla \c"
I think the attempt is to terminate echo without a new line.
If it does not work on your system, you can replace this way,
echo "test \c"; echo " same line"
can become,
echo -n "test"; echo " same line"
An easier change will be (as suggested by Neil, +1 there),
echo -e "test \c"; echo " same line"
You have to give it exe. permissions.
So: chmod +x new_file
When you create a new file with your gcc, by default, this isn't executable. So, you have to gave it permissions of execution.
With chmod (see this) you change permissions on file.
In that specific case, you gave execution permissions ( + [plus] means gave, 'x' means execution ) to that file.
If you want to revoke that permission, you can type: chmod -x filename
After compiling, the file is placed in a.out
Try to use a.out.
C is not an interpreted language like Python or Perl. You cannot simply type C code and then tell the shell to execute the file. You need to compile the C file with a C compiler like gcc then execute the binary file it outputs.
For example, running gcc file.c will output a binary file with the name a.out. You can then tell the shell to execute the binary file by specifying the files full path ./a.out.
Edit:
As some comments and other answers have stated, there are some C interpreters that exist. However, I would argue that C compilers are more popular.
If you have a single foo.c, see if make can compile it for you:
make foo
No makefiles or anything needed.