I'm trying to write a program with the function of find_a()... i haven't learned this yet so i was wondering if anyone knew anything about it or could point me in the right direction to find out something about it...
13 1377
Never heard of it. Its not part of the STL.
What package/lib does it apply to?
Never heard of it. Its not part of the STL.
What package/lib does it apply to?
My professor called it a hypothetical function. And also said This function will take a arbitrary input stream reference as a parameter, then read characters in from the stream until it finds an 'a'. The function should then return the number of characters read.
I'm pretty sure i know how to have it count the number of characters. Its more or less trying to figure out how to use find_a().
My professor called it a hypothetical function.
Ah! This means the function does not actually exist in any real library. You are to imagine this "function" being part of some class "out there".
And also said This function will take a arbitrary input stream reference as a parameter, then read characters in from the stream until it finds an 'a'. The function should then return the number of characters read.
I'm pretty sure i know how to have it count the number of characters. Its more or less trying to figure out how to use find_a().
So to use it, you will need to know 1) what you pass to it, 2)what it does to what you pass to it, and 3) what it returns. Then you can figure out how to use it.
Ah! This means the function does not actually exist in any real library. You are to imagine this "function" being part of some class "out there".
So to use it, you will need to know 1) what you pass to it, 2)what it does to what you pass to it, and 3) what it returns. Then you can figure out how to use it.
ok he said our main function only needs these two lines of code: - cout find_a(cin);
-
return 0;
Right. So your find_a() function is going to read chars from that stream until it comes across a specific character.
What is your question about this? Are you trying to implement one?
Right. So your find_a() function is going to read chars from that stream until it comes across a specific character.
What is your question about this? Are you trying to implement one?
like i know id start off with - int main()
-
cout find_a(cin)
-
return 0;
-
and then there should be more
im thinking i should use int istream and then a do while loop to count.... does that sound right?
but other than that I'm kind of lost on what to do...
What is your question about this? Are you trying to implement one?
. . .
im thinking i should use int istream and then a do while loop to count.... does that sound right?
An int istream. Now what would that be? And a do while loop to count. Count what?
No offense, but it sounds like you have no idea what is going on. Making guesses is a bit pointless in programming.
When I’m stuck, I imagine a big square in my mind. There’s lines that are protruding from the left and right. This represents a black box, and is a way of forcing myself to look at something as such. On the left are the inputs, and on the right are the outputs. Start with this model. Find_a is now a black box. It can be used in the form cout << find_a(cin); Clearly there is a single input (cin), and some form of output, which goes to cout. If my last sentence was not dead obvious, let us know.
So the question is, what is the datatype of the input, and what is the datatype of the output. This is what you need to answer first. If you cannot even answer this, then you might as well give up. Look at the description of what your professor gave you:
This function will take a arbitrary input stream reference as a parameter, then read characters in from the stream until it finds an 'a'. The function should then return the number of characters read.
. So, what is the datatype of the input and output? Do not give us a vague response. Until you can tell us an answer that a compiler would accept, we will not proceed.
the datatype of my input is char... and the datatype of my output is an int because i want to count the amount of letters until i reach a letter a...
am i not right with what i just said??
your input is going to be coming from a stream you won't be receiving a single char. take a look at the return type of cin. Although i don't know how to handle Function(cin); I don't see where you allow the using to input in the stream.
You are right about the output. It is an integral value. So an int. But you are most certainly wrong about the input. You're telling me the input is a char. Well, it's not even close.
Here's an example of a char: 'a'. or 'b'. or 'c'. One character. Remember, I said precise. If you tell the compiler, char, it will expect a char. Not two. Not five. Not many of them. Just one. But it's not even characters. As was said, cin is an object of istream. I'm pretty sure your professor covered streams, if he's giving you this assignment. So read up on istreams.
So we have an istream as input. And an int as an output. Write the function declaration. I don't want a definition (the body of the function). Just the function declaration. This needs to be compilable. You can make a mistake here, in just one line of code, so that's why I'm asking you to do this.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dan McCoy |
last post by:
I'm new to MYSQL, having just finished my website.
I have 1 thing left to try and do to make the site experiance as seemless as
possable, but to do it I figure I need to do some sort of mysql...
|
by: news.rcn.com |
last post by:
How can I access the request and response object for a page using
javascript. I want to stick some data on with something like
request.setAttribute( "User's choice for later use" ).
I can't seem...
|
by: Peter Lin |
last post by:
Dear all;
I need to monitor a xml file so that I can update my data in
hashtable, but the problem is it will trigger more than one event for
a lastwrite action(I trigger this action by add...
|
by: Shane Story |
last post by:
My other thread on serialization seemed to be stagnant and I still have
questions, so I decided to post this example of what I need to know.
I am trying to use binaryformatter. I have no trouble...
|
by: satan |
last post by:
I need a help with the program to test the insertion, deletion, search, copyList, and the copy constructor operations for an object in the class UnorderedLinkedList.
These are my classes:
...
|
by: satan |
last post by:
I need a help with the program to test the insertion, deletion, search, copyList, and the copy constructor operations for an object in the class UnorderedLinkedList.
These are my classes:
...
|
by: John Paul |
last post by:
I'm thinking of building an e-commerce site in php.
Anyone got any advice in building one?
What is the best way to implement a payment system?
Are any legal issues involved?
Thanks,
|
by: jesper_lofgren |
last post by:
Hello, i need to help here.
I have a xmlnode as you can se below (full xml is in the bottom). I
wonder how i can get the values inside the CSammanstallningLista .
<CSammanstallning...
|
by: jesper_lofgren |
last post by:
Hello, i need to help here.
I have a xmlnode as you can se below (full xml is in the bottom). I
wonder how i can get the values inside the CSammanstallningLista .
<CSammanstallning Id="Omrade"...
|
by: shaunb |
last post by:
Hi, just new to this forum, and i was wondering if anyone could help me.
I've got a piece of work to do, i have done the majority of it, just the last, and the most important thing lol, that i am...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
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: 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...
| |