Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is this possible to do in C++ {Novice Programmer}

Reply
Thread Tools

Is this possible to do in C++ {Novice Programmer}

 
 
AMT2K5
Guest
Posts: n/a
 
      06-27-2005
"FILE* setFp(char []) - setFp is passed a null terminated character
array that contains the name of a file. Before attempting to open the
file check the state of fp. If fp is not null close fp. Open the file
in read mode using fp. Return fp."

In my assignment it wants the setFP function to take in a nameless
parameter? I am used to seeing something like "char a[]", not just an
empty variable name. How do I act on the incoming string if it has no
name?

class Bank
{
FILE* fp;
}

FILE* Bank::setFP(char [])
{
//some code goes here
}

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      06-27-2005
AMT2K5 wrote:
> "FILE* setFp(char []) - setFp is passed a null terminated character
> array that contains the name of a file. Before attempting to open the
> file check the state of fp. If fp is not null close fp. Open the file
> in read mode using fp. Return fp."
>
> In my assignment it wants the setFP function to take in a nameless
> parameter? I am used to seeing something like "char a[]", not just an
> empty variable name. How do I act on the incoming string if it has no
> name?


I think you're looking too much into the details of the assignment.

Function declarations do not need argument names, only the types. So,
whoever wrote that assignment decided to omit the name for your own
benefit: so you could name it as you wish. If you think you need to
use that argument, you will have to call it something. If you want it
to be 'a', use 'a'. If you want your code to be self-documenting, do
not use single-letter variable names.

> class Bank
> {
> FILE* fp;
> }
>
> FILE* Bank::setFP(char [])
> {
> //some code goes here
> }
>


V
 
Reply With Quote
 
 
 
 
AMT2K5
Guest
Posts: n/a
 
      06-27-2005
Ok, thanks for the tip.

Can I now do, fp = fopen(a, "r"); ?

I think I forgot how to set the pointer to the incoming string.

 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      06-27-2005
AMT2K5 wrote:
> Ok, thanks for the tip.
>
> Can I now do, fp = fopen(a, "r"); ?


Should be alright. Are you getting a compile error?

> I think I forgot how to set the pointer to the incoming string.


I am not sure I understand this comment.

V
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
efficient data loading with Python, is that possible possible? igor.tatarinov@gmail.com Python 10 12-14-2007 04:44 PM
is it possible to possible to create an iterator from a callback interace? aninnymouse@gmail.com C Programming 4 02-21-2006 02:10 PM
XML + XSD: Is it possible to get all possible Values for an Element? Markus Java 1 11-22-2005 02:51 PM
Possible to connect 2 computers via USB? Michael Giroux Wireless Networking 2 09-02-2004 03:27 AM
Possible domain related wireless problem =?Utf-8?B?QWxpIEQ=?= Wireless Networking 0 08-10-2004 01:59 AM



Advertisments