C++ :: Output Vowel From User Input - Error With Strings And Functions

Nov 25, 2014

The program is supposed to read in a string from the user and then output the number of each vowel that the string has. My first function is initializing the vectors, and the one that I'm having trouble with is the function used to read the string from the user and save it.

Here's my code:

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;

// FUNCTION PROTOTYPES GO HERE:
void init_vectors(vector<char> & vowels, vector<int> & frequencies);
string read_text(const string & prompt);

[Code] ....

And I'm getting the error:

freq.cpp: In function ‘std::string read_text(const std::string&)’:
freq.cpp:74: error: no matching function for call to ‘getline(std::istream&, const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)’

I'm not too sure if I can't use the function getline here or if there is something wrong with the function prototype itself but I'm pretty sure there isn't an error there as it was given to me.

View 4 Replies


ADVERTISEMENT

C++ :: C Type Strings - Program To Ask User To Enter A String And Perform Functions

Oct 18, 2014

My assignment is : Please use C type strings ( array representation of strings). Write a program that will ask the user to enter a string. It will then regard that string as a worked-on string and allow the user to perform the following editing functions on it:

s – search
i – insert
a – append
d – delete
a – append
d – delete
r – replace
e – exit
s – search

This option will allow the user to search for a specified string in the worked-on string. If the string is

found, it will display the starting index (position) of the searched string in the worked-on string.

here is what i have so far.

#include <iostream>
#include <cstring>
using namespace std;
int main() {
char a_string[80];

[Code] .....

View 4 Replies View Related

C++ :: Wap To Read A Character From User And Test Whether It Is A Vowel Or Constant

Jan 10, 2014

How to do this?

View 10 Replies View Related

C :: Input From User As Char And Output In Hex Form

Sep 9, 2014

I'm trying to write a program that takes input from the user (thats a char) and outputs it to the monitor in hex form.The program is meant to continuously take input from the user then output to the monitor in hex form until an EOF is detected this triggers the program to close.The following code does this except that I get a lower case 'a' at the end of each output.I think the 'a' has to do with the enter key and if that is the case how can i tell the program to ignore this input from the user.

Example: input from user: ABC output to monitor: 41 42 43 a

Code:
#include <stdio.h>
int main(void) {
char myChar;
while(EOF != (myChar = getchar())) {
printf("%x ",myChar);
}
system("pause");
return 0;
}

View 5 Replies View Related

C++ :: Converting User Input Int To String Output?

Apr 22, 2014

I am writing a code in a class that will change the user input which is integer to a string. For example if the user enter 13347..the output should change to "one three three four seven" on the user screen.I'm not getting the right output.

Code below:

#include <iostream>
#include <string>
using namespace std;
string arr[]={"one","two","three","four","five","six","seven","eight","nine"};
class convertTo{
public:
int signed num;
int convet(){
cout<<"Enter a number to convert to string "; cin>>num;

[code]....

View 2 Replies View Related

C/C++ :: Program To Allow User Input And Output Perfect Number

Mar 11, 2014

The problem that I am having is that , the program outputs numbers that are perfect numbers and im not sure where i can add a statement to make it so that if it isn't a perfect number it doesn't output...

#include<iostream>// allows user input/output
#include<conio.h>
#include<fstream>//data file / result file
#include<iomanip>
#include<cmath> // math function
#define in_file "data.txt"
#define out_file "result.txt"

[Code] ....

View 3 Replies View Related

C++ :: Output Multiplication Table From Two User Input Integers Between 2 And 10?

Jan 14, 2015

So I'm supposed to write something that will output a multiplication table from two user input integers between 2 and 10.

For example it should display like this is the user inputs 4 and 5

1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20

I was hinted to used two for loops and this is what I have thus far, what I can't figure out is how to display it like the example.

#include <iostream>
using namespace std;
int main() {
int num1;
int num2;
cout << "Enter two numbers between 2 and 10." << endl;

[Code] .....

View 2 Replies View Related

C/C++ :: Input User Name And Height In Inches And Output In Centimeters

Oct 22, 2012

I am attempting to write a simple C program, in which the user is asked to input their name and height in inches and the output is the user's height in centimeters.

I have attached my program and what happens when I try to run it.

Attached Images : PM.jpg (120.6 KB)

View 1 Replies View Related

C++ :: Prompt User For Two Characters - Output Movies That Begin With Input

Nov 24, 2014

I have trouble printing out the movies starting with inputing only two letters.

#include <iostream> //cout, cin, endl,getline
#include <fstream> //ifstream
#include <cstdlib> // exit
using namespace std;

const int NUM_MOVIES = 116792;
struct Movie {

[Code] ....

View 1 Replies View Related

C++ :: Program Will Echo Letter (User Input) And Output Name Of The Day Of Week

Oct 21, 2012

Write a C++ program that does the following:

Prompt the user to enter a day of the week as M (or m), T, W, R, F, S, and U for Monday through Sunday respectively. The user may enter an upper or lower case letter.

When the user enters a character, the program will echo the letter and output the name of the day of the week.

Provide an error trap that reads something like "you have entered an invalid letter; program aborting." Suggestion: use a switch statement with the error trap as the default condition. it is not necessary to prompt for multiple inputs.

So I know how to get the program to echo back the letter and everything. What I am a little confused about is: will I have to define all the letters as their respective day? eg. make M== Monday. And if I do have to do that how would I get it to accept Upper and Lower case letters and recognize that that letter is == monday ect. ect.

Also my main problem is the switch statement as the error trap. I have never used the switch statement, but I know what they do. I just don't really understand how I would use it for an error trap. Am I suppose to just make a case for every other letter in the alphabet other then M T W R F S and U? Even if I do that then what if the user enters a number instead of a letter?

View 4 Replies View Related

C :: Unscramble User Input - Error In Loop

Sep 24, 2014

The purpose of this program is to unscramble the user's input. for example if the user entered 'ftooabll' the program would print 'football'. find the error that I am making....

Now, this only works for strings that are contained in the file wordlist. That being said, I would like this to repeat this search multiple times. Currently, the process is being repeated 7 times, but it only works on the first iteration. The code and sample input/output is below.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUMLOOP 6
void sort_string(char*);

[Code] ....

Sample input/output: (note: all data has been verified to be in the wordlist)

Enter string:
4132dcba
abcd1234
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba

View 3 Replies View Related

C++ :: How To Error Check If User Input Is Letters And Not Numbers

Jun 9, 2014

How do I error check if the user is inputting letters and not numbers? For example, if the user inputs "Lab.txt" I need to display an error message. If they input "Lab2part2.txt" then this is correct and what I want.

I've found a lot of information online on how to error check for numbers or a single letter (EX: 1,2,3, etc. or 'A' 'B' 'C') but nothing for actual WORDS or maybe I should refer to it as a string of characters?

Is there any way to do this? Because my program requires I ask the user to input the name of the file. But the way my code is currently set up is even when the user inputs the wrong file name it still opens the file. I want to prevent this from happening so my thought was to error check user input.

/*Program to determine company's weekly payroll*/

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void OpenTheFile() {
ifstream inputFile;
string filename;
char letter;
int number;

[Code] .....

View 1 Replies View Related

C++ :: User Input Data About Percentages To Calculate Final Grade - Addition Error?

Sep 15, 2014

I am trying to code a program that takes in user inputted data about percentages and using it to later on calculate a final grade. 4 percents are inputted, for Assignments, Midterm1, Midterm2, and Finals. If the percents dont add up to 1 (i tell the user to enter the decimal value) I set up and if statement to catch it and end the program. Except that if i type in

Assignments = .3
Midterm1 = .3
Midterm2 = .3
Finals = .1

the program doesn't recognize that they add up to 1. Heres the relevant portion of my code [URL] ....

Here's some examples of how it works [URL] ....

And heres what i dont understand [URL] ....

Why is it saying .3 + .3 + .3 + .1 != 1 when .1 + .3 + .3 + .3 == 1?

View 1 Replies View Related

C++ :: Looping - Input Numbers Until User Types 0 Then Output Product Of Non Zero Numbers

May 1, 2014

How to do the problem below using loop?

Input numbers until the user types a 0, then output the product of the non 0 numbers: e

E.g., if the user types 2 4 6 0, the program should output 48

View 3 Replies View Related

C++ :: How To Output Array Of Strings

Feb 5, 2013

How do you use a for loop to iterate through strings to display them in a console?

View 3 Replies View Related

C++ :: Using Vectors And Strings / How To Output Name With Lowest Age

Nov 5, 2013

I have to write a program in C++, without using a selection sort, that outputs the name you enter with the lowest age. You input 5 names with ages and at the end it outputs the youngest person. This is what I have so far:

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()

[code]......

I Know for the second for loop there has to be if statements in it but I am so stuck on what to write next.

View 3 Replies View Related

C++ :: Two Dimensional Array Output Strings

Feb 8, 2014

I have an array of strings and a two dimensional array made up of floats. In the output for the strings (this array stores 10 divers numbers) I am getting only 8 of the numbers, then a core dump. What could cause this?

View 17 Replies View Related

C++ :: Reading Series Of Strings Into Array Then Output

Feb 24, 2015

The requirement was to set the txt files information equal to a variable before and not to put it directly into the array.

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
const int MAX = 24;
struct applicant_info {

[Code] .....

the txt doc looks something like this: file name: jobs4.txt

View 2 Replies View Related

C++ :: Output Of Dumpbin Export To See Functions Of A DLL

Apr 22, 2013

From the console of VCE I have run dumpbin export as

Code: dumpbin /export myDLL.dll

in order to see which functions is the dll providing. I got as an output:

Code: ordinal hint RVA name
1 0 00024B0 _Function1@4
2 1 00024E0 _Function2@0
.....
I think RVA means Relative Virtual Address, but what does the @4 or the @0 (or @16) means?

BTW the @# notation is a c-style function naming convention where the number is the size of the parameters accepted by the function. 4 might be an integer or a pointer on a 32-bit system.

If this is the case, I am guessing a @12 might mean three integers and @16 four integers?

View 1 Replies View Related

C++ :: User Array Size And Sorting User Input

Nov 1, 2014

I am making program that allows the user to determine how big the array size will be and then asks the user to make up numbers to fill the array. Every time run the program on Dev C++ it says "program has stopped working"

Heres My Code:

//Assignment 19 Program 2
#include <iostream>
using namespace std;
int main()

[Code].....

View 3 Replies View Related

C/C++ :: Ignore Strings From Being Entered By User?

Oct 6, 2014

how I can ignore strings from being entered by the user. When the use enter's a string it always evaluates it as even. I though I might use a cin.ignore(); but I am unaware of how to use it.

#include <iostream>
using namespace std;
int main() {
cout << "Enter a number: ";
int num = 0;

[Code] ....

View 2 Replies View Related

C++ :: Overloading Output Stream And Pure Virtual Functions?

Aug 7, 2013

I'm working with inheritance and pure virtual functions, and I want to overload an output stream operator. However, every time I run the program I get this: 0x7fff00ee98c0.

I'll include a base class and a derived class so you can see what I'm talking about.

Base:

#include <iostream>
using namespace std;
#ifndef _Insurance_h_
#define _Insurance_h_

[Code]....

The application is something like this (I'm assuming the user has already inputted the name, salesperson, make, model, etc):

#include "Auto.h"
#include <iostream>
using namespace std;
#include <vector>
vector<Insurance *> sales;

[Code] .....

View 4 Replies View Related

C/C++ :: Input Validation With Strings And Int

Apr 15, 2014

I am having a problem with my "void Validation :: getId()" function its suppose to get the id number from the user but when I try and type a letter to see if it catches it, it goes into this continuous loop. Also with my "string Validation :: getName(string name)" function it suppose to catch the comma in the user input for their last name , first name but doesn't catch it and still returns the name back to main function.

#include "InputValidation.h"
#include <iostream>
using namespace std;
Validation :: Validation() {
name = " ";
id = 0;

[Code] ....

View 1 Replies View Related

C/C++ :: How To Input Strings Into 3D Array

Feb 19, 2014

I was very much confused with managing the 3d arrays. Other than initialising it is tough for me to input the data into the 3d array at runtime. I have tried the every possible method i know untill now but i can't successfully input and output the data.

I have written a code by declaring the 3d array of char s[5][2][20] in main and passing it's base address into another function, lets say input(char (*p)[2][20],int ,int ,int). I have passed the 3 dimensions in declaration 5,2,20 to the input function i have used these 3 values as the subscript for the pointer p and tried to input the data. But i wasn't successful.

How to input the strings into the 3d array.

My preferences were:

1.The change of subscript value should take place in loop(eg:for).
2.Which indexes should be used for inputing the data through pointer.
3.Use either "scanf" or "gets" function to inputs the data and print using "printf" or puts.

View 1 Replies View Related

C++ :: String With Vowel Removal?

Mar 5, 2014

I'm trying to write a program that uses a loop to remove vowels from words. I'm really bad at this programming thing, I am getting an error code "[Error] expected unqualified-id before '{' token" when compiling, so there's no telling at this point if the code will even work. But, I need to get rid of that blasted error.

Here's my code:

1 #include <iostream>
2 #include <string>
3 #include <vector>

[Code]......

how to take an image to post in the forums. So I had to copy/paste/edit to fit :/.

View 3 Replies View Related

C++ :: Error Debugging With Functions?

Oct 7, 2014

I am remaking this code for my gain, and it seems that I cant debug the error..

Are there any comments on the structure of the code? Why are there errors in calling the functions?

#include <iostream>
#include <cmath>
#include <iomanip>

[Code].....

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved