473,396 Members | 2,010 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,396 software developers and data experts.

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

"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
}

Jul 23 '05 #1
3 1013
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
Jul 23 '05 #2
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.

Jul 23 '05 #3
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
Jul 23 '05 #4

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

Similar topics

5
by: Michael Jones | last post by:
I m getting a parse error on this snipet of code and I can't understand why: for ($i=0; i$ < $num_results; $i++) { $row = mysql_fetch_row($result) echo $row; } It doesn't like the for...
8
by: Star | last post by:
Hi, I would like to do the following. If the user types this URL in the browser: http://www.mysite.com/john I want it to be redirected to http://www.mysite.com/showuser?user=john The...
2
by: Internet Citizen | last post by:
I'm a little confused about this: BOOL bTest=_istpunct(147); In my ASCII chart, code 147 represents an open quote symbol, a "curled" quote. But bTest is FALSE (0). It's false whether or not I...
15
by: AMT2K5 | last post by:
Hello folks, I seem to have recieved a segfault within my function but am unsure on how to resolve it. I understand that it means that somewhere something is trying to access memory that is not...
10
by: SueB | last post by:
I currently have a 'mail-merge' process in my Access db project. It generates custom filled out Award Certificates based on an SQL SELECT statement in a VBA routine invoked by clicking on a...
76
by: Alan Connor | last post by:
-- Alan C this post ends with w q From K&R: #include <stdio.h> main()
4
by: trond | last post by:
Hello all, Before I start I'd like to point out that I am a complete novice when it comes to asp.net - My background is in network and operating systems, and although I have been doing a bit of...
1
by: The Confessor | last post by:
For my previous project, I stored persistent data from Structures in three different Random Access files between sessions, but that's not likely to be an option with this one... For starters,...
11
by: Ranginald | last post by:
This question is about how to handle an .aspx page that references multiple methods and where to store these methods (e.g. one codefile or multiple codefiles). PREFACE ======== I have a simple...
4
by: Chelonian | last post by:
I'm considering trying to learn Python for a specific reason, and hoped the group might help me get a sense for whether it would be worth my time. The situation... Me: total beginner w/ a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.