C++ :: Incorrect Operands And Undefined Identifier
Apr 25, 2013
I'm writing a program to read in a Master.txt file and then update it through a Transaction.txt file that contains various transaction types [Adds (A), Deletes (D), and Edits (E1-E4)]. The records in both files are in ascending order based on Item#. Ultimately, the original Master.txt and updated Master file (Master2.txt) will be merged to reflect all valid transactions, and an errorLog.txt file will be created to indicate all invalid transactions. I feel I have all of the code written correctly, but I am still getting errors on my operands and identifiers.
I have some code does not compile. I think it's missing an included library, but not sure.
In the int main() block of code, the following three items give errors:
1. Mtrx (the one following "new") - Error: expected a type specifier 2. result - Error: expected a ";" 3. &result - identifier "result" is undefined
Below is the code with the head to show you what has been included:
HTML Code: #include <iostream> #include <iomanip> using namespace std; #include <limits.h> // create the structure of the matrix struct Mtrx { int numRows; int numCols; float array[101][101];
The exercise consists on 3 procedures. We get the information from a .txt like these:
01/03/2011 A 02/03/2011 F 03/03/2011 C 04/03/2011 T (...)
Simulating a Videoclub database where the letters stand for the type of movie (A=Action, T=Terror, C=Comedy, ...) and the dates they were rented.
a) How many movies from one specific genre have been rented more than 'n' times? The genre and the value 'n' must be entered by the user.
b) How many movies and which genres belong to a certain date? The date must be entered by the user.
c) Print a list that shows the number of times a movie from each genre has been rented.
So far this is what I've got:
Code: #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 100
typedef struct { int dia,mes, any; char genere;
[Code] ....
But right now, my main problem is that I can't even debug because i get an error in line 97 --> while (llista[i][j] != EOF) <-- saying "invalid operands to binary != (have 'lloguer' and 'int').
I've tried to cast (int) before "llista[i][j]" but it says that I'm already supposed to get an integer from that.
I can't seem to figure out the algorithm to find the right permutation(s) of operands and operators.
We basically have a list of 6 unsigned integers. Using arithmetic operations (addition, subtraction, multiplication, division), find the arithmetic expression that evaluates to a target integer.
I've created a class that works with vectors doing various calculations and what not. I have overloaded operators that I've created outside of the main in separate header and class files. Ive tested them and the overloaded operators work correctly when I paste them into a the main file but when I have them defined in the other class files and I try to access them in the main class I get an error saying invalid operands to a binary expression. I also have other classes with overloaded operators that work just fine in the main class so I'm not sure what I did wrong here?
This is how I have my header set up, the definitions to these are in a separate class file which I don't think I need to include considering I have them tested and working so I don't think that's the problem (correct me if I'm wrong).
#include "Name of vector class" int main(){ vector<float> vR, v1, v2; v1.push_back('some value'); ... v2.push_back('some value'); ... vR = v1 + v2; // Invalid operands here return 0; }
And like I said, I have other classes with overloaded operators set up the same way which work fine being implemented the way I have these, so I'm not sure where the problem is at.
Currently I am trying to convert RGB to HSL. Everything is working but the saturation value. It is always close to the correct value (usually less than 10 off). For example:
I am writing a program where I read in data from a file into an array and a 2D array. However, when I cout that data to insure that it was all read in correctly, I get only the first full line of that input file(where there are actually 25 rows and 12 columns).
What am I doing wrong or should be doing differently?
ifstream fin; //open the input file fin.open("store_data.txt"); //If input file was opened, read input file data into array and 2d array if(fin){
PROGRAM:- #include<fstream.h> //for reading and writing files #include<conio.h> //for clrscr() #include<string.h> //for string characters #include<stdio.h> //for gets and puts function #include<process.h> //for exit function #include<iomanip.h> //for setw function #include<dos.h> //for delay and sleep function
Were are to implement a method countValue() that counts the number of times an item occurs in a linked list. Remember to use the STL <list>
int countValue(list<int> front ,const int item);
Generate 20 random numbers in the range of 0 to 4, and insert each number in the linked list. Output the list by using a method which you would call writeLinkedList which you would add to the ListP.cpp.
In a loop, call the method countValue() , and display the number of occurrences of each value from 0 to 4 in the list.
Remember that all the above is to be included in the file ListP.ccp
I'm doing a bitwise operations on 2 bytes in a buffer, then storing the result in a variable. However, I sometimes get a non-zero value for the variable even though I'm expecting a zero value.
The relevant portion of the code is as follows.
unsigned int result = 0; long j = 0, length; unsigned char *data; data = (unsigned char *)malloc(sizeof(unsigned char)*800000);
[Code] ......
I'm expecting result to be zero when my data[j] and data[j+1] are 0xb6 and 0xab respectively, which is the case for most of the time. However, for certain values of j, my result is strangely not zero.
j = 62910, result = 64 j = 78670, result = 64 j = 100594, result = 64 j = 165658, result = 512 j = 247990, result = 128 j = 268330, result = 512 j = 326754, result = 1 j = 415874, result = 256 j = 456654, result = 1024 j = 477366, result = 512
It appears that these strange result values are all powers of 2, with a 1 bit appearing somewhere in the unsigned int.
I'm not changing the value of result anywhere else in the code, and when I print out (unsigned int)(((data[j]^0xb6)<<8)|(data[j+1]^0xab)), I get 0, but somehow when it gets stored in result, it's no longer zero.
Program: I have 2 arrays: 1 for the correct answers to a quiz, 1 for the user. I then have a vector to hold the incorrect answers. It keeps outputting what looks like alt characters, why.
Here is the code:
#include <iostream> #include <vector> using namespace std; int main()
My loop is outputting data incorrectly. I have inbound web data that come in sets of 7. I am trying to in insert the 7 records into a vector and then display the vector content followed by a new line.
We have to make a code to detect the frequency of printable characters. But when I run the code, sometimes it can't detect the Uppercase Letters. But it can sometimes. It's a bit buggy, and it really can't get the frequency of the space character.
Does textcolor affect the outcome?
Code: #include<stdio.h>#include<conio.h> int main () { clrscr(); char name[40],sentence[1000],ch; int c=0,count[95]={0}; textcolor(LIGHTCYAN);
[Code] ....
I also noticed that it stops detecting the frequency when there is a space between character/s.
I'd wrote a program to encrypt a message within a bmp file using my own structs and all for everything (yes, call me a ........head) The program works but for some weird ........ing reason I was forced to subtract 2 bytes from the header size to get the correct value. I've narrowed down the issue to my BmpFileHeader struct.
Here's a short program that demonstrates the issue:
Code: #include <stdio.h> #include <stdlib.h>
#define BYTE unsigned char #define WORD unsigned short #define DWORD unsigned long #define LONG signed int
[Code] .....
Tried with both gcc and TinyCC and got the same result so it doesent seem to be a compiler bug. Microsoft's structures though are giving the correct size, even though they have the exact same definition.
Microsoft's defines:
Code: // windef.h typedef unsigned long DWORD; typedef unsigned char BYTE; typedef unsigned short WORD;
This program has to convert an unsigned binary number into a decimal number. No matter what binary number I enter, however, it always outputs that the decimal number is 0.
My code is as follows:
#include <iostream> #include <cmath> #include <algorithm> using namespace std; int main() { string binarynumber; cout << "Enter an unsigned binary number up to 32 bits." << endl;
[Code] ....
And my output:
Enter an unsigned binary number up to 32 bits. 00001111 That number in decimal is 0
The output should have shown the binary number in decimal to be 15, and I cannot find my error.
I've implemented the merge sort algorithm and used the 'merge' part for counting the number of split-inversions in an array as part of an assignment for an online course. How ever, the out put array is not a sorted version of the input array and as a result the number of split inversions obtained is wrong. I think that there is some thing wrong in the way I am indexing arrays.
I've used ' cout ' to print the values of indexes to see exactly what values are being passed in during the recursions.
Code:
#include <iostream> using namespace std; int length=0,mid=0,inv=0; void mergesort(int arr[], int first, int last) { cout << "first: " << first << " " << "last: " << last; cout << endl;
I have an issue with a switch case in my program. I execute it and it does fine all the way up to where it says, "Answer (1, 2, or 3): ". When I enter 1, 2, or 3, it gives me' "Not an input choice!" from the default of the switch case.
NOTE: I use Code::Blocks on Windows XP.
Here is the code:
Code:
#include <stdio.h> #include <string.h> int main() {