Ok, so I have this array of strings that I want to compare to make sure its a number, so I been thinking atoi, but I cannot get it to compile, how would I compare the stuff inside an array of strings to an interger? The bolded and underlined part is my problem
code:
code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int argc, char *x[]){
if(argc !=3){
printf("Must have two arguments.\n");
exit(0);
}
int d,z,j,l,i,t;
int buffer;
for(i=1;i<argc;i++){
for(j=0;j<4;j++){
if(x[i][j]=='\0'){
break;
}
buffer=0;
for(t=0;t<10;t++){
[U] [B] if(atoi(x[i][j])==0){[/B][/U]
buffer++;
printf("%d",buffer);
printf("\n%d,%d\n",i,j);}
}
if(buffer==0){
printf("Arguments must be a number.\n");
exit(0);}
}}
z= atoi(x[1]);
d= atoi(x[2]);
l= z * d;
printf("%d\n",l);
return 0;}