char str[]=argv[]; How do you expect that to work? str is an array of chars and argv is an array of char pointers. When you're declaring an array, you must know it's size beforehand. The only time when you write char str[] = ... is when you immediately initialize with {'a', 'b', ...} or "ab...". If you wanted to put the contents of the first argument into an array of your own, you'd write
1 2
char str[11];//assuming the input won't be more then 10 chars long
strcpy(str, argv[0]);
But there is really no reason to do that at all. Why not just atoi(argv[0])?
Ask yourself what does atoi return and what is the type of str. Does it make sense to assign them to one another? Ask the same for str and result.
Also, you're missing a ");" after argv[0]. I'm sure the compiler is giving you very clear messages about what is wrong. Just read them.
Also, you're missing a ");" after argv[0]. I'm sure the compiler is giving you very clear messages about what is wrong. Just read them.
thx for the reply, atio extracts integer values from chars so i changed the code a bit and instead of assigning atoi(argv[0]) to a character type (str) i assigned it to integer and passed it to display,its working now.