C/C++ :: Error - Expected Unqualified-id At End Of Input?
Apr 3, 2014#include<iostream.h>
#include<stdio.h>
#include<conio.h>
using namespace std;
class CV {
public:
char name;
char qualfctn;
[Code]....
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
using namespace std;
class CV {
public:
char name;
char qualfctn;
[Code]....
I can't figure out this error.
#include <iostream>
using namespace std;
bool isPrime(int number); {
primeNumber = isPrime(number);
[Code] ....
This first Dowhile loop is saying "expected unqualified-id" at the do and while parts. What does that mean
do {
do {
do {
std::cout << "Give me a test result or grade from 0 to 100 for class"<< 1 << std::endl;
std::cin >> mathaverage[mathtestcount];
loopresult=1;
[Code] .....
I'm working on a school project learning C++. I'm running into an error I can't seem to find the answer for (see topic title).
main.cpp
#include <iostream>
#include <string>
#include "Signature.h"
#include "Genome.h"
using namespace std;
// Calling Function
int main() {
Signature Sig1; // Create Signature object
Genome gString1; // Create Genome object
[code]....
I'm pretty new to C, and keep getting an error. Basically I'm trying to convert a ppm image to all red. Here is my code that I can't get to work:
Code:
change(pixel_t *PIXEL, &w, &h,pixel_t *buffer);
And here is the beginning of my convert function:
Code:
void change(pixel_t *pixel, int w, int h, pixel_t *buffer) {
int average, sum;
int i;
pixel_t *pointer;
Everything else works fine. I keep getting an error when I call the convert function. It says "expected expression before pixel_t" and "too few arguments to function "change". I know that everything else in the main is working.
im making a checkers game but i keep getting a 'expected a statement' error on the first 2 'else's
void Initialise(){
for(int row=0; row<3; row++) {
if(int row=0<3)
//player 1 pieces
string player = "Player 1";
for(int col=0; col<8; col++)
[code]....
I have a program that rolls two dice however many times the user specifies and counts the occurrences of each total (2-12). I have to compare the results of the random rolls to the expected outcome and give the percentage of error between the two.
I have an example that tells me the sum to expected outcome are as follows if I roll 36 times: 2/1, 3/2, 4/3, 5/4, 6/5, 7/6, 8/5, 9/4, 10/3, 11/2, 12/1 but I don't know how to put that into code to get the expected outcome for X amount of rolls.
Error message is identifier expected and declaration terminated incorrectly.
//to define a class Employee
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<conio.h>
class cEmp {
[code]....
The code is supposed to display the total and averages of the data as well, but cuts off due to an error in the code.
Since this code is quite lengthy, I will be breaking it up into two posts.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
[Code].....
ofstream infile;
infile.open("Input.txt");
if(infile.fail()) {
cout << "Error Opening File in Input" << endl;
system("pause");
exit(1);
}
So I'm trying to see if it fails, but if i change "Input" name would the computer just create a new file name of it for example if i change "Input" to "asdf" the computer is just going to create "asdf" how do i fix it.
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
The code is supposed to display the total and averages of the data as well, but cuts off due to an error in the code. The code should also:
1)Print checks for all employees, one per page, sorted by lastname. The first check number, 100, is to be read from a company data file (see requirement 4). The border of each check is important and should not be omitted.
2)Convert the net pay to a text string for each check printed.
3)Print a reference code on each check. The reference code is obtained by combining the first letter of the lastname with all the consonants remaining after removing all vowels (a,e,i,o,u).
4)Use the same employee data found in assignment 2. Use company data, obtained from a text file, for each check printed:
Spoiler
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef short BOOLEAN;
typedef char STR15[15 + 1];
typedef char STR10[10 + 1];
typedef struct PayRecord
[Code] .....
I have not completed this program yet, but I have already run into a snag. For the Input Validation part, every time you enter a number regardless if it is positive it will still display the cout statement: "Please enter positive values". The program runs correctly where I currently am at, but it just keeps reading that statement even if a user enters a positive value. I have run the debugger, but it really is not showing me anything other than I notice it jumping to that statement after every value that is entered.
Here is my code, once again I have not finished this yet, but I would really like to get this fixed first before I continue. I will keep debugging in the meantime...
Code:
// A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 X 7 array, where each row represents a different monkey and each column represents a different day of the week. The program should first have the user input the data for each monkey. Then it should create a report that includes the following information:
// Average amount of food eaten per day by the whole family of monkeys.
// The least amount of food eaten during the week by any one monkey.
// The greatest amount of food eaten during the week by any one monkey.
// Input validation: Do not accept negative numbers for pounds of food eaten.
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double totalAverage = 0; // variable to store the total average, initalized to zero
[Code] ......
#include <iostream>
int ival1
int ival2=1
int summe
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main() {
[Code] .....
If I compile it I've got these errors
[Error] expected initializer before 'int'
recipe for target 'rechnen.o' failed
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] .....
I keep getting an error here and cant quite figure out why,
Code:
else if (mainMenu == 3){
cout << "Please make a selection" << endl
<< " 1) Withdraw from account" << endl
<< " 3) Back to main menu" << endl;
cin >> withdrawMenu;
if (withdrawMenu == 1){
[Code] ....
I wrote a program, that generates 20 random integers, and stores them in an array. Then I decided, to build more functions to it, i.e why not have it to display the lowest integer of an array. I created my function,
Code:
int minValue( int field[ ] )
and got my code in side, which (technically) works. In my main() function I'm calling
Code:
printf( "The smallest value of an array is: %d
", minValue( field[] ) );
and I'm getting an error trying to compile it.
Code:
randomArray.c:62:74: error: expected expression before ']' token
printf( "The smallest value of an array is: %d
", minValue( field[] ) );
This is what i have example code in c++:
#include <iostream>
class Foo{
public:
void bar(){
std::cout << "Hello" << std::endl;
[Code] ....
After compiling it is giving error as :
foo.cpp: In function ‘int Foo_max(Foo*)’:
foo.cpp:26:37: error: expected primary-expression before ‘int’
foo.cpp:26:46: error: expected primary-expression before ‘int’
I have a global var (m) with an initial value 5.
I have a template class (A) that derives from a either a base class that has a member (_A1.m) or not (_A0), based upon it's template parameter. class (A) has a member function (fn) returns the value of (m) as it understands what (m) is.
However, this gives different results compared with a non-template class in a similar scenario. I'm expecting that if derived from _A1, that m should be taken from the base class scope and if derived from _A0, it should be taken from the global one.
Here is the code for your amusement:
int m = 5;
class _A0 {
public:
_A0(int) {
[Code] ....
This compiled using g++ 4.5.3 and 4.6.3 with the same results:
Global value of m is: 5
B0 class has no internal m member. Object resolves m internally with value 5
B1 class has internal m member. Object resolves m internally with value 3
A<_A0> class has no internal m member. Object resolves m internally with value 5
A<_A1> class has internal m member. Object resolves m internally with value 5
In this code:
#pragma once
#include <iostream>
class CBox // Derived class {
public:
// Constructor
explicit CBox(double lv = 1.0, double wv = 1.0, double hv = 1.0) : m_Length(lv), m_Width(wv), m_Height(hv){}
[Code] .....
Before the program ends, at return 0;
I would expect the CBox destructor to be called 3 times but it is being called 6 times? Why? Also in this code:
#pragma once
#include <iostream>
class CBox // Derived class {
public:
// Constructor
explicit CBox(double lv = 1.0, double wv = 1.0, double hv = 1.0) : m_Length(lv), m_Width(wv), m_Height(hv){}
[Code] .....
Why is the destructor called 3 times? When have you really destroyed a CBox? Doesnt emplace only create it and store it, then thats it?
[URL] .....
For pushback:
void push_back(value_type&& _Val)
{// insert by moving into element at end
if (_Inside(_STD addressof(_Val)))
{// push back an element
size_type _Idx = _STD addressof(_Val) - this->_Myfirst;
[Code] .....
Im building a banking system. in my create_account it asks for account address and phone number as well as other questions. When I go to my Show account info (balance inquiry) I notice its not getting the right address as well as phone number. its showing "garbage".
Code:
/********************************************************************
* Vincent Dotts 09/29/2014 ch11.cpp *
* This program serves as a customer banking system *
*****************************HISTORY*********************************
* WHO DATE Discription *
*********************************************************************
* VD 09/30/2013 Created program *
********************************************************************/
#include<iostream>
#include<fstream>
[Code] .....
Here's my code. The error's at the last line.
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define max_con 30
void add_contact();
void edit_contact();
void del_contact();
void list_contact();
[Code] .....
I am trying to get this simple validation loop to work so that it only displays the error message when the input is outside the range 1-3. yet it always seems to display the message.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int Menu ();
int ValidInt(int , int );
[Code] ....
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.
I just wrote the following simple program:
Code:
#include <stdio.h>
#include <math.h>
int main(void) {
float fx, x;
[Code] ....
The output increases x by 0.1 as expected until x=1.5. After that x becomes 1.600001 and not 1.6 as expected.
I'm trying to perform a simple input operation, and check to make sure that whatever the user input is a valid input (is within data type bounds, is correct data type...). But when I get to ignoring the input, I keep getting an error.
unsigned short num;
while (true) {
std::cin >> num;
if (std::cin.fail()) {
num = 1;
[Code] ....
I don't fully understand why this error is here.