Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Regarding C Coding
Regarding C Coding
Given:
Line in file Contents
30 int * someIDs, theFirst, *r;
110 someIDs =GetSomeIDs(); /* defined below */
111 theFirst = someIDs [0];
112 r= ReorderIDs(someIDs);
113-150 /* we want to use ‘theFirst’ and ‘r’ here*/
499 /*-------- GetSomeIDs-----*/
500 int * GetSomeIDs()
501 {
502 int ids[8];
503-550 /* The ids are defined here */
551 return ids;
552 }
✍: Guest
Answer Questions below
Correct the problems with GetSomeIDs(), and add some additional functionality to it, as follows. A single new version of the function should be provided.
The new version should:
a) Maintain the same "int *" return type which returns a pointer to fixed sized array of ints.
b) IN ADDITION to its regular function return, provide to its calling functions a usable array of pointers to aliasID structures. The length of this array of pointers is returned by a call to GetNumberOfAliases(), which you may call only from within GetSomeIDs().
c) Use the structure and the functions defined below:
typedef struct {
char* alias; /* '\0'-terminated C string */
int specific_id;
} aliasID;
/* How many structures should be pointed to by the array
*/
int GetNumberOfAliases(void);
/* Get a pointer to the next structure. The structure itself
* will be filled with data.
* Caller is responsible for the cleanup of the returned structure
* and its content. The latter are allocated in
* dynamic memory.
*/
aliasID * GetNextAlias(void);
Do NOT(!) use "C++" syntax or language contructs.
This should be written in plain “C”.
Use good programming practice, as much as these instructions allow.
2010-05-12, 11196👍, 0💬
Popular Posts:
How To List All Values of Submitted Fields? - PHP Script Tips - Processing Web Forms If you want lis...
How To Escape Special Characters in SQL statements? - MySQL FAQs - Introduction to SQL Basics There ...
.NET INTERVIEW QUESTIONS - How to prevent my .NET DLL to be decompiled? By design .NET embeds rich M...
What is the difference between "printf(...)" and "sprintf(...)"? sprintf(...) writes data to the cha...
What is COCOMO I, COCOMOII and COCOMOIII? In CD we have a complete free PDF tutorial of how to prepa...