I am trying to take input from the STDIN. If the input string starts with character '$' then the input is not converted to string as it is.
int main(int argc, char*argv[]){
printf("%s\n",argv[1]);
}
Can someone please let me know to why C compiler replaces the characters with '0' if it encounters the '$' symbol ?
It's not your program. It's your shell interpreting it as a variable, then passing its value to your program.
To work around this, escape the $
when you invoke the program from your shell.
./yourprogram '$arg'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With