![]() |
|
#1
|
|||
|
|||
pointers to pointersI've run this through the debugger and the problem I continue to have is that the pointers inside my function are not passed back to the main program. I took screenshots of it to you show you what I mean.
harddrivecaddy.com After I learned about pointers to pointers I rewrote my function but got the same result. I've tried a hundred variations but all return the same result. Here's my code: CPP / C++ / C Code:
Last edited by LuciWiz : 01-Aug-2005 at 00:26.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#2
|
||||
|
||||
|
Please read the Guidelines and pay close attention to guideline #1.
You really need to explain what you're trying to do because without the background of what and why, the how is unknowable. It looks like you have some serious memory leakage if you ever do get this to work the way you're going. Using a convoluted pointer to pointer hodgepodge like this can cause a lot of grief in the long run. Also, because strdup() is non-standard it's compiler-dependant. Information I have is it already does a malloc() and you must remember to free it before you lose track of the buffer it creates. You probably should not use functions that internally malloc buffers because it's easy to lose control of your memory. __________________
Age is unimportant -- except in cheese |
|
#3
|
|||
|
|||
|
My whole program is written with character arrays. The opensource URL class I downloaded is written with the string library. I'm trying to convert the string values to character arrays.
|
|
#4
|
||||
|
||||
|
Quote:
__________________
Age is unimportant -- except in cheese |
|
#5
|
||||
|
||||
|
I don't know much about pointers, but the following code does what you are trying to do, as long as the string is not more than one line long. As I do not know the commands to create files in c++, I used the system command.
CPP / C++ / C Code:
|
|
#6
|
|||
|
|||
|
Quote:
The code's purpose is to parse a URL and update the host, get, and query pointer arguments. Then I'm going to use that data to create a socket and perform a request to a web server. I want this function to act as a wrapper to the string class. Class is here: freshmeat.net |
|
#7
|
||||
|
||||
|
Quote:
Let me rephrase the question. What is CPP / C++ / C Code:
__________________
Age is unimportant -- except in cheese |
|
#8
|
|||
|
|||
|
Quote:
string -> const char * -> char * I want it to return a pointer to the converted string that is now a character array. In other words, takes a string and returns a char. |
|
#9
|
||||
|
||||
|
So just use the c_str() method in the main routine and forget all this pointer business. if foo.get_net_path() returns a string type
CPP / C++ / C Code:
Or better yet, find a character version of the function in C instead of using the C++ string version. __________________
Age is unimportant -- except in cheese |
Recent GIDBlog
Meeting the populace by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with an array using pointers | glulu76 | C++ Forum | 1 | 01-May-2005 11:21 |
| [Tutorial] Pointers in C (Part II) | Stack Overflow | C Programming Language | 0 | 27-Apr-2005 17:36 |
| array of pointers to ...... | kai85 | C++ Forum | 1 | 18-Apr-2005 17:06 |
| [Tutorial] Pointers in C (Part I) | Stack Overflow | C Programming Language | 1 | 08-Apr-2005 18:35 |
| Help with C++ pointers | Mjkramer21 | C++ Forum | 23 | 18-Apr-2004 07:53 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The