I just solve informatic problems in c++. I have a string array of data which I want to make some comparing with a temp string array so it can move on. That's easy. I use loops and ifs. But the problem is that I use it many times and I want to organize my program. Therefore, i intend to pass the string array of data as a parameter in a particular function. In fact, I would really be appreciated if I can transfer a parameter data type of a string array by reference. Anyways a lot of help would be appreciated.
How do I transfer an array table to a function as a parameter in the syntax programming of C++?
char strArray[][6] = {"AAAAA", "BBBBB", "CCCCC", "DDDDD", "EEEEE"};
int stringCount = sizeof(strArray)/sizeof("AAAAA");
int TestStringArray(char A[][6], char B[])
{
for(int i = 0; i %26lt; stringCount; i++)
{
if(0 == strcmp(A[i], B))
{
return i;
}
}
return -1;
}
void main()
{
char B[] = "EEEEE";
int result = TestStringArray(strArray, B);
}
jasmine
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment