This question is about C Programming. How can i convert the arguments accepted from main and convert it to integer?
For example, consider this simple program :
void main(int argc, int **argv)
(The program compiles and runs fine.)
I have assigned the integer argv to "a" which is the first argument at the command line.
when i look at the results i get a junk character as the output for the second " printf " statement. When i use %s to print the argv it prints the correct number, but if i use %d it prints a junk character. In this case how can i assign an argument accepted as an integer in the command line to an integer variable?
I have tried typecasting it : a=(int)argv does not work, neither does a=(char*)argv; work. where am i doing a mistake?
Please explain how this works.