![]() |
|
#1
|
|||
|
|||
another c simple questionDear All, I don't know how to make the function
SetFile in this program work without change it become CPP / C++ / C Code:
Anybody pls explain more why the SetFile not work. When should i pass parameter to function by value or by reference? why both void CopyKata ( kata Tin , kata *Tout) and void CopyKata ( kata *Tin , kata *Tout) work. Acctually this program derived from several file i just cut some funtion from them. Please just ignore that i just assign many variable with zero. here is the program CPP / C++ / C Code:
Last edited by LuciWiz : 20-Oct-2004 at 05:27.
Reason: Please insert your C code between [c] [/c] tags
|
|
#2
|
|||
|
|||
|
It wont work becuase, your CopyKata() expect "Tout" argument as a pointer to the varibale of type kata. So you need to pass "address of TFile[i] in (*T) as &((*T).TFile[i])" and not "T.TFile[i]" where in you are passing start address of structre T.
Sorry, if that doesn't explain it well. Anyway,changing your SetFile() to the one below will work. CPP / C++ / C Code:
Also, in Copykata() instead of copying single characters at a time using for loop, you can simply use string copy function strcpy() as below.(Unless there is a specific reason for it to do that way). CPP / C++ / C Code:
Same in PrintTable(). you can change it to CPP / C++ / C Code:
When I complied and executed the code with these changes, I got following output CPP / C++ / C Code:
|
Recent GIDBlog
Developing GUIs with wxPython (Part 2) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| very simple c question | if13121 | C Programming Language | 1 | 18-Oct-2004 00:12 |
| New to this forum...just a little question... | rune hunter | C++ Forum | 4 | 16-Oct-2004 09:33 |
| question of practice | magiccreative | C++ Forum | 1 | 06-Feb-2004 07:17 |
| Simple Question regarding installing Apache 2.0 | macjoubert | Apache Web Server Forum | 0 | 13-Nov-2003 11:39 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The