|
-
Jul 30th, 2001, 04:02 PM
#1
Thread Starter
Lively Member
Returning char*/char [] from a function
Hey,
I am having a big problem! I have this function I've written and basically I want it to pass me a "string" (note I am using C not C++). I am currently returning the pointer from a character array in the fuction... but that method is severly flawed!
When it returns different values and puts them in different variables all of the variables equal the last value sent to a varaible..
example:
char *cgidata(myQuery, myVar)
}
char myVarValue[30];
...
return(myVarValue);
}
int main()
{
char *myLog;
char *myPass;
...
myLog = cgidata("login=test&pass=nopass", "login");
myPass = cgidata("login=test&pass=nopass", "pass");
...
}
myLog ends up equaling myPass because myPass was called later!
I got around it by using sprinf(charArray, charPointer); but it only put the first 4 characters that were in the pointer into the Array!
What do I need to do!?! Can I return an Array Value not a pointer from my function? If so... what is the syntax...
Thanx!
Brandito
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|