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

Need info

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...
Oct 25 '07 #1
13 1377
RRick
463 Expert 256MB
Never heard of it. Its not part of the STL.

What package/lib does it apply to?
Oct 25 '07 #2
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().
Oct 25 '07 #3
sicarie
4,677 Expert Mod 4TB
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.
Oct 25 '07 #4
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:

Expand|Select|Wrap|Line Numbers
  1. cout find_a(cin);
  2. return 0;
Oct 25 '07 #5
sicarie
4,677 Expert Mod 4TB
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?
Oct 25 '07 #6
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

Expand|Select|Wrap|Line Numbers
  1. int main()
  2. cout find_a(cin)
  3. return 0;
  4.  
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?
Oct 25 '07 #7
but other than that I'm kind of lost on what to do...
Oct 25 '07 #8
sicarie
4,677 Expert Mod 4TB
What is your question about this? Are you trying to implement one?
. . .
Oct 25 '07 #9
oler1s
671 Expert 512MB
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.
Oct 26 '07 #10
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...
Oct 26 '07 #11
am i not right with what i just said??
Oct 26 '07 #12
Studlyami
464 Expert 256MB
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.
Oct 26 '07 #13
oler1s
671 Expert 512MB
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.
Oct 26 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

0
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...
3
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...
4
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...
0
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...
1
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: ...
7
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: ...
7
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,
1
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...
1
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"...
6
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
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,...
0
Oralloy
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,...
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
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,...
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...

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.