473,411 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

help please

line 50 - char *b, q, *r;

line 200 - b = getbuf ();

Line 201 q = *b;

Line 212 R = anotherfunction (b);

Lines 213-2003 /* we want to use 'q' and 'r' here */

Line2000 char * getbuf ()

Line2001 {
Line 2002 char buff [8];

Lines 2003-2050 /* unspecified buff defined here */

Line 2051 return (char*) buff;

Line 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 no use) C++ syntax. Include statement in
called and calling functions. Use good programming practice.

9. What's the difference between system calls and library functions?

Dec 12 '05 #1
5 4551
Can anyone suggest me a good link for pointers and memmory management??
Thanks

Dec 12 '05 #2
ch*******@yahoo.com wrote:
[homework questions]


A good many of these are covered in the comp.lang.c
Frequently Asked Questions (FAQ) list at

http://www.eskimo.com/~scs/C-faq/top.html

Begin your studies there.

--
Eric Sosman
es*****@acm-dot-org.invalid
Dec 12 '05 #3
"ch*******@yahoo.com" <ch*******@yahoo.com> writes:
[...]
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.

[snip]

I'll give you the standard response: give us your instructor's e-mail
address so we can submit the answers directly.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 12 '05 #4
"ch*******@yahoo.com" wrote:

line 50 - char *b, q, *r;

line 200 - b = getbuf (); [...] Line 2051 return (char*) buff;

Line 2052 }

1. What will be in variable 'q' after line 201 is executed?
Under what conditions might this not be so? [...] 9. What's the difference between system calls and library functions?


This exact message was posted, verbatim, back on Oct. 3, under the
subject "C question - Know the answers to the following".

So, either this is a serial drive-by troll, or the result of someone
supposedly teaching C to clueless newbies.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Dec 12 '05 #5
<ch*******@yahoo.com> wrote:
line 50 - char *b, q, *r;

line 200 - b = getbuf ();

Line 201 q = *b;

Line 212 R = anotherfunction (b);

Lines 213-2003 /* we want to use 'q' and 'r' here */

Line2000 char * getbuf ()

Line2001 {
Line 2002 char buff [8];

Lines 2003-2050 /* unspecified buff defined here */

Line 2051 return (char*) buff;
You are returning a pointer to an auto array. This is really bad because
it might work, by chance, from time to time. The quick fix is to change
line 2002 to:

static char buff[8];

The proper fix usually is to change the ownership of the array to a higher
level (outer) function.

Why did you provide a (char*) cast on the return statement? Did it fail to
compile without the cast?

Your post is too cryptic to my taste and you try to get *way* too much
information from a single post.

Line 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?


<snip questions 4, 5, 6, 7, 8 and 9>
Dec 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
1
by: the_proud_family | last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com I can't get the ball to go up right side and then I need it to turn around and keep turning until velocity=0 I have been at it for the ...
0
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web...
12
by: Christo | last post by:
borland c++ 5.01 character constant must be one or two characters long get this when compiling my first c++ program can anyone out there help? it is highlighting this line as the problem ...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
17
by: JT | last post by:
Help me the following C++ question: Write a program to help a local bookshop automate its billing system. The program should do the following: (a)Let the user enter the ISBN, the system will...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
2
by: =?Utf-8?B?U2NvdHRSYWREZXY=?= | last post by:
I'm creating a doc project for my c# program. I've done this before but this time sonething is wrong. I build my doc project and is succeeds but when I open the help file, there is no documentation...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.