Reading string character by character in C
27,126
sample
#include <stdio.h>
int main(int argc, char *argv[]){
int i,j;
for(i=0; i<argc; ++i){
for(j=0; argv[i][j] != '\0'; ++j){
printf("(%c)", argv[i][j]);
}
printf("\n");
}
return 0;
}
Author by
aNobody
Updated on September 27, 2020Comments
-
aNobody over 3 years
So I have a string passed into main function: int main(int argc, char* argv[])
I understand argc (which is 2 in this case), but don't understand how I can read argv[] character by character? When I print argv[0] shouldn't that print the first character in the array of characters for that string?
Thanks