ARGC/ARGV Strangeness - Code is working
pking123-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org
pking123-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org
Wed Sep 21 03:45:50 UTC 2005
Below is the code that finally works. I have by now heavily modified
this program to, first of all, go forward in the list rather than
backward; as well as to accept a range of numbers rather than a list.
So, I christen this first effort "backascii.c" :-)
The new, properly-working program is completed and is the one called
"ascii.c". Thanks to all who made suggestions. Biggest thanks goes to
Peter Fletcher, who made valuable suggestions, especially regarding
debugging.
Paul King
----------8<--------snip----------8<--------snip---------------
#include <stdio.h>
#include <strings.h>
int main (int argc, char *argv[]) {
/* this only takes a number as an argument */
int num = 0;
int count;
char p1[5];
for (count = argc - 1; (count > 0); count--) {
strcpy(p1, argv[count]);
num = atoi(p1);
printf ("%d\t'%c'\n", num, num);
}
return 0;
}
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list