![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to return void function pointer | umen | High Level Programming | 1 | 03-22-2008 01:01 PM |
| Function Problem and CoreDump | ZINGARO | Shell Programming and Scripting | 8 | 02-19-2008 03:37 PM |
| pointer problem | useless79 | High Level Programming | 1 | 11-07-2007 11:24 PM |
| PERL function problem | avadhani | Shell Programming and Scripting | 2 | 06-15-2005 01:18 AM |
| Problem with the strlen function in ksh | steiner | Shell Programming and Scripting | 3 | 07-24-2003 05:39 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
i have a function:
char *pcCityIdToCountryName(ADMIN_DB_DATA *pstHEader, unit uiCityID) this returns a pointer to CountryName if cityId is given. to retrieve countryname i give: char *CountryName; CountryName = pcCityIdToCountryName(..................); but when i compile it is giving : Unresolved pcCityIdToCountryName Iam new to C programming. Please help |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
The compiler (actually the linker) is telling you that it can't find the
char *pcCityIdToCountryName(ADMIN_DB_DATA *pstHEader, unit uiCityID) code anywhere. Is this function in another module? If so you will have to link against that module. Code:
cc myfile.c -o myfile -L<some shared library> or cc myfile.c somemodule.o -o myfile Code:
libcountry.so becomes: -L country |
|
#3
|
|||
|
|||
|
Thankx for the reply!
As u have said the function is in another file called admin.c, but everything is included in Make file..... does Unresolved means an error... or can it be ignored????? |
|
#4
|
|||
|
|||
|
unresolved = fatal error
unresolved means the linker could not find it. The program must have it. The program will not run without it. |
|
#5
|
|||
|
|||
|
Thank u. I got the solution.
|
|
#6
|
|||
|
|||
|
Your other post implies you may be passing back a string.
You may prefer to use strcpy like so: char CountryName[XX*]; strcpy(CountryName, pcCityIdToCountryName(..................) ); *where XX is the size of the string. The reason being is that you don't know if the char pointer being passed back is still pointing to an allocated memory block. Sometimes I have seen functions pass back a pointer to a local variable or memory being allocated and then made free. It just so happens that you are pointing to a memory location that still has a string (null terminated) value. This may not be the case later on in the program's execution, especially when you are allocating and freeing memory frequently, and you may encounter a memory violation. At least by copying string into a local variable you can protect against any future problems. Of course, if it is your own function, you can make your own judgements as to the best way to call it, based on your overall design.
__________________
Senior Analyst/Programmer |
|||
| Google The UNIX and Linux Forums |