I am working on a program that is meant to return values to another app based on certain chars entered into the program. It is not important what they do, since that is off topic.
What I do need to know is why my conditional operator isn't being evaluated. This condition is only meant to check if a value of argv[1 through argc-1] in a nested loop, and set an array value called "flag" to 1 that is incremented in the base loop.
This is the header for my program. quosym.h
#include <stdio.h>
char file_quosym[10]={'@','$','#','&','x','[','(','s','*'};
Just a simple 2 lines, array intended to be global obviously.
And here is the program.
CODE
#include "quosym.h"
int main(int argc,char *argv[])
{
int flag[10]={0}, i=0, j, ret;
while (argc--) //Until argvs last valid index is reached
{
for (j=0; j<9; j++) //Run through fil_quosym array for every char in argv
{
flag[j]+=((char)argv[i]==file_quosym[j]) ? (1) : (0);
}
i++;//Head to next value in argv
}
return 0; //Ignore this. Still pondering proper way to return it.
}
int main(int argc,char *argv[])
{
int flag[10]={0}, i=0, j, ret;
while (argc--) //Until argvs last valid index is reached
{
for (j=0; j<9; j++) //Run through fil_quosym array for every char in argv
{
flag[j]+=((char)argv[i]==file_quosym[j]) ? (1) : (0);
}
i++;//Head to next value in argv
}
return 0; //Ignore this. Still pondering proper way to return it.
}
This was my error message from the compiler (Dev C++)
ISO C++ forbids comparison between pointer and integer
This was indifferent whether the char typecast was there or not.
Changing the ?: to an if ((char)argv[i]==file_quosym[j]) was no different.
Am I unable to get char values from argv? What's my best course of action here?