| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Testing - part 2 |
Hello Neil.
28 Jun 04 17:18, you wrote to all:
NH> 9. Consider the following snippet of C code for looking up the size
NH> of a user's address book. Assume that fetchEntries( ) and
NH> freeEntries( ) are already written and do the right thing (allocate an
NH> array of entries and fill in the correctly allocated array,
NH> respectively):
NH> int fetchEntries( int userid, int * countp, entry_t ** entrypp );
NH> int freeEntries( entry_t * entryp );
NH> int getEntryCount( int userid, int * countp) {
NH> int count;
NH> entry_t * entryp;
NH> int errcode;
NH> errcode = fetchEntries( userid, &count, &entryp );
NH> if (errcode) return(errcode);
NH> freeEntries(entryp);
NH> countp = &count;
should be *countp = count;
NH> return 0;
NH> }
that's answer 'd'
NH> 10. How could you fix this code to work correctly?
NH> b) Dereference countp before assigning it to count (instead of
NH> assigning countp directly).
Is that an attempt to describe the change I gave above? (C I undestand,
English still gives me trouble occasionally)
NH> d) Pass in &entryCount to fetchEntries( ) instead of &count.
If the examiner means pass in countp instead of &count that would work,
except possinly when there's an error.
Jasen
--- GoldED+/LNX 1.1.4.7
* Origin: (3:640/1042)SEEN-BY: 633/267 270 @PATH: 640/1042 531 954 774/605 123/500 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.