Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 13th, 2005, 1:15 PM   #1
ndumbane
Newbie
 
Join Date: Apr 2005
Posts: 3
Rep Power: 0 ndumbane is on a distinguished road
Need help on a program--- Came to find out it was not a PERL Program!

Hi to all,

I am a QA analyst with 5 years of experience. I would like to get some help on this program. Suggestions or comments would be much appreciated. It is NOT homework, just to reassure you.

Thank you




LINE Contains
50 char * b, q, *r;
200 b=getbuf();
201 q = *b;
212 r= anotherfunction(b);
213-300 /* we want to use ‘q’ and ‘r’ here*/
2000 char * getbuf()
2001 {
2002 char buff[8];
2003-2050 /* unspecified, buff defined here *./
2051 return (char *) buff;
2052 }

1. What will be in variable ‘q’ after line 201 is executed? Under what conditions might this not be so?



2. Is there an alternative, but equivalent, way to write line 2000? If so, what is it?



3. Is getbuf() a reasonable function?



4. Will getbuf() execute at all?



5. Please comment on line 2051.



6. Is getbuf() good practice, and why?



7. What line not given should be provided for compilation?



8. How, exactly, could one get a second ‘char *’ to use back from this function? Be specific in terms of the exact syntax needed. (That is, provide code.) Another way to state this question is how can this function be modified to return a ‘char *’ (that is, it maintains the same return type) from the function, and an additional ‘char *’ value in one function call. Please make sure that your answer will work even if the size of the char * desired is not known in the outside calling function. Avoid (do not use) C++ syntax. Include statements in called and calling functions.
ndumbane is offline   Reply With Quote
Old Apr 13th, 2005, 2:08 PM   #2
peace_of_mind
Professional Programmer
 
peace_of_mind's Avatar
 
Join Date: Sep 2004
Location: Hell if I know most of the time
Posts: 439
Rep Power: 5 peace_of_mind is on a distinguished road
Send a message via MSN to peace_of_mind Send a message via Yahoo to peace_of_mind
That's not even code. Almost like pseudocode. Where'd you get this "project" from?
__________________
Amateurs built the ark
Professionals built the Titanic

peace_of_mind is offline   Reply With Quote
Old Apr 13th, 2005, 3:05 PM   #3
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
lmao...
iignotus is offline   Reply With Quote
Old Apr 13th, 2005, 3:06 PM   #4
ndumbane
Newbie
 
Join Date: Apr 2005
Posts: 3
Rep Power: 0 ndumbane is on a distinguished road
Help in program.

It is a pseudocode. Any idea. Any input or help would be much appreciated.

Thank you.

Ndumbane
ndumbane is offline   Reply With Quote
Old Apr 13th, 2005, 3:07 PM   #5
ndumbane
Newbie
 
Join Date: Apr 2005
Posts: 3
Rep Power: 0 ndumbane is on a distinguished road
Quote:
Originally Posted by peace_of_mind
That's not even code. Almost like pseudocode. Where'd you get this "project" from?
It is a pseudocode. Any idea. Any input or help would be much appreciated.

Thank you.

Ndumbane
ndumbane is offline   Reply With Quote
Old Apr 13th, 2005, 3:09 PM   #6
jgs
Newbie
 
Join Date: Apr 2005
Posts: 2
Rep Power: 0 jgs is on a distinguished road
Line 2000 is the beginning of the getbuf function definition. It defines the fuction's interface. It means that a function named getbuf will take no parameters (any paramters would be listed inside of the parenthesis) and will return a pointer to a character (char *). Everything between the brackets on lines 2001 and 2052 define what the function does.

We don't really know what it does because lines 2003 through 2050 are missing. However, it doesn't really matter what it does because you are returning a pointer to the address of the first element of an array that only exists within the scope of the getbuf function.

Line 2000 creates an array of characters with a length of 8. This array is only valid within the closing brackets of the getbuf function. Line 2051 returns a pointer to the beginning of the array, but it's of no use to the calling program (see Line 200 where getbuf is called) because after the function returns control to the calling program, the array is gone.
jgs is offline   Reply With Quote
Old Apr 13th, 2005, 4:00 PM   #7
peace_of_mind
Professional Programmer
 
peace_of_mind's Avatar
 
Join Date: Sep 2004
Location: Hell if I know most of the time
Posts: 439
Rep Power: 5 peace_of_mind is on a distinguished road
Send a message via MSN to peace_of_mind Send a message via Yahoo to peace_of_mind
Quote:
Originally Posted by ndumbane
It is a pseudocode. Any idea. Any input or help would be much appreciated.

Thank you.

Ndumbane
You asked for help on a program, then list questions about your pseudocode. And I'm to believe it's not an assignment? Post the code you have so far and I'll try to help.
__________________
Amateurs built the ark
Professionals built the Titanic

peace_of_mind is offline   Reply With Quote
Old Apr 13th, 2005, 11:06 PM   #8
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
i agree with piece_of_mind...

besides, I thought you "QA guys" only dealt with the end product?
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:18 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC