skip to Main Content

hope someone can help.

I’m working on a problem set passing arguments in C99 on Ubuntu, part of the problem set specifies that non-integer characters should lead to an early return from the main function and program termination.

For example:

#include <stdio.h>

int main(int argc, string argv[])
{
    // code
}

I’ve discovered that if I pass the program a ' character at the end of a series of digits e.g. ./runme 12345' it seems to open some kind of shell/prompt.

Can anyone help with what this is?

2

Answers


  1. Chosen as BEST ANSWER

    As John3136 wrote in a comment:

    It's the shell interpreting the quote and expecting you to enter more stuff then a clo[s]ing quote.


  2. This is not related to C, but to your shell. In bash, a single quote has special meaning to the shell, and if you want to pass it to some other program, you have to quote it, for instance

    ./runme 12345'
    

    or

    ./runme "12345'"
    

    This applies of course to all shell meta-characters.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search