C++ :: CRC 32 Calculation Of File
Jan 3, 2014i need to calculate crc32 of a input file and check with the original crc value of a file and return true/false,
View 4 Repliesi need to calculate crc32 of a input file and check with the original crc value of a file and return true/false,
View 4 RepliesI am trying to work on a C++ program to calculate the quadratic formula using input files and classes. I have written my class, but I am trying to find a way to take an input file with unknown number of lines of coefficients. How do I take each integer from each line and set that value as "a" and "b" and so forth, then start over on the next line?
This is what i have so far.
fstream inputfile;//users input quadratic coefficients file
ofstream outputfile;// outputs a file with solutions
int main(int argc, char *argv[])// argc is argument count, char *argv[] is array of array of characters for arguments {
string dataline;
getline(inputfile, dataline);
[code].....
I have a text file in the form
5502 5202.3
1523 2536.1
1254 1256.2
17846 8956.2 and so on
left one is time and right one is pressure, I need to show the time value as it is but i need to use the pressure value to calculate air speed. I don't know how to use the strings to pick up the list properly. I did the calculation formula for the air speed but i can't pick the pressure value up from the text file. here's what i did:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
[Code].....
I tried to write a simple program to calculate monthly yield, APR, and principle in various directions. Anyway, here's some code to get the APR from the principle and monthly yield. When I run it though, it spits 0 at me every time! What the problem is; the other functions work just fine and the code line for the APR calculation is just what it ought to be - I see neither a math nor tech problem here.
Here is the offending function:
Code:
void calculateAPR() {
int principle, monthlyYield, apr;
cout<<"
Please input the principle:";
cin>>principle;
cin.ignore();
[code]....
I would like to ask about how we calculates the following bitwise expression.
Code:
unsigned char ch[2] = {0x49,0x49};
ch[0] | ch[1] << 8; I'm thinking ch[1] << 8 as 0x00 ...
So, I think that the above expression converts to 0x49 | 0x00 ... and the complete expression should be 0x49 for me.
But, the compiler gives me the result of 0x4949 as two bytes.How does the compiler calculate this expression as two bytes?show me the steps included in the calculation of this expression?
I want to have calculations take place inside a switch statement that calls the appropriate function. The menu portion of the program works well, but I can't figure out how to let the user actually input 2 different numbers to the functions. My questions are:
1. If I use scanf to assign values to the variables, what determines end of input to each variable? (ie.. scanf("%d%d", &a, &b) what is the end of a, what is the end of b?)
2. Should I assign the variables to user input inside the switch, or try to do it in the functions below?
3. Is there something I haven't thought to ask that will screw me over? I'm really new to this.
Code:
#include<stdio.h>
int add(int b, int a);
int mult(int b, int a);
main() {
[Code] ....
This really was a test of multilayer menu, but I want to add functionality if I can.
Changed a variable before posting and didn't change all the conditions testing it.
void viewWasteReport(){
EXEC SQL BEGIN DECLARE SECTION;
char wasteid[5],wastetype[31],month[11],wastequantity[13],wasteweight[11];
//double wastequantity[13];
//double wasteweight[11];
EXEC SQL END DECLARE SECTION;
fnConnectDB();
[Code] ....
I want to obtain the the product of wastequantity*wasteweight, but i get error.
I am trying to calculate a CRC of a Base64 string.I give you the correct checksum : 2942042514...And now the string :
AQAAAAAAAABsYAAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0d2XIaSbI+hZ13
m0NCR0QNE7KOHcXKlkMwtnhyIIRkdjGwgGxpP35386jqursRsk0zQygkd+dR
lVmVmZVdl//3Xyl+E4/iixiJivgqBmIm5mIoJmIsfhW/iLp4LWrwbwUwY9EH
[code]....
I tried CRC 16, 32 and with polynomial 0xEDB88320L, and with all these tries, I cannot find the correct checksum, it is my main problem.I don't want C++ code source, but I am searching for the method or algorithm to find it. If you want to know, this string in base64 contains an string compressed in zip, which contains an UTF16 XML. I want to modify information, and modify Adobe Projet (prproj)
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
[Code]....
Write a program that outputs inflation rates for two successive years and whether the inflation is increasing or decreasing. Ask the user to input the current price of an item and its price one year and two years ago.
To calculate the inflation rate for a year, Uh, no, that’s wrong! To calculate the inflation rate for a year, subtract the price of the item ONE YEAR AGO from the price of the item for that year and then divide the result by the price a year ago. For example: 2014-Inflation-Rate = (2014-Price minus 2013-Price) / 2013-Price.
Your program must contain at least the following functions:
•a function to get the input
•a function to calculate the results
•a function to output the results
I need to create average calculating program using do while loop.
t = 1 - sin(x) when x > 0;
t = 1 + x when x = 0;
t = a + sin(x) when x < 0;
primary information:
x changes from 1 to -1 by step h = -0.5, a = -2
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main() {
int a = -2;
[Code] ....
How this program should look that's why this probably looks just like a mess.
I am trying to calculate a CRC of a Base64 string. I know the answer of the checksum, but I don't how to calculate it (It is for Adobe project).
I give you the correct checksum : 2942042514
And now the string :
AQAAAAAAAABsYAAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0d2XIaSbI+hZ13
m0NCR0QNE7KOHcXKlkMwtnhyIIRkdjGwgGxpP35386jqursRsk0zQygkd+dR
lVmVmZVdl//3Xyl+E4/iixiJivgqBmIm5mIoJmIsfhW/iLp4LWrwbwUwY9EH
+C1gx+KesH+IjjgTr4Bqj2h+Ey0hxRHQTMQNcHwSV/A0EYsA3oFSFlDngDAf
[Code] ....
I tried CRC 16, 32 and with polynomial 0xEDB88320L, and with all these tries, I cannot find the correct checksum, it is my main problem.
Is there any possible way of calculating some values at compile time? I have the following code of genereting upto 2000000010 palindrome numbers.
Code:
#include <iostream>
#include <string>
#include <sstream>
#include <string.h>
#include <stdlib.h>
[Code] .....
As you see, I have taken input from the user just after calculating the whole palindromes. So cant we calculate this at compile time? because runtime of this program is extremely slow.
Another qs. I first tried to use array but It didnt allow 2*10^9 sized array. so what should I do whenever I need that size of array?
I wrote a function to do factorization (n!). while this function works perfectly:
Code:
int fact (double x){
register int z=1;
if (x==0)
return 1;
else
for(x;x;x--)
z*=x;
return z;
}
this doesn't:
Code:
int fact (double x){
if (x==0)
return 1;
else
for(x;x;x--)
x*=x;
return x;
}
what makes the second one different from the first one? can't see the difference..
Why do i keep getting wrong results
Code:
#include "stdafx.h"#include <stdio.h>
#include <string.h>
nt main(void){
char name[40];
int numbers[50];
[Code] .....
I am basically trying to make a program for a calculator. I am struggling with how to do the sine calculation. this calculation will take place at line 158.
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double firstNumber = 0.0;
double secondNumber = 0.0;
char operation =' ';
[Code] ....
I'm working on a payroll program and I'm having problems that are causing calculation errors.
My input file is
1234FredJones4025.00
2345 TerrySmith6010.00
The errors I get are from the regular pay, over time pay, gross pay, tax amount and net pay calculations. They all look similar to this (6e+002). I believe they are occurring because regular pay isn't calculating correctly and the rest depend on that for their calculations. However, I can't see why regular pay isn't calculating correctly.
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
class payroll{
ifstream fin;
char employeeid[100];
[Code] .....
// DEBUG3-4
// This program contains a class for a cylinder
// Data members are radius and height
// The volume is calculated as pi times radius squared times height
// If no height is given, it's not a cylinder - it's a circle!
#include<iostream>
using namespace std;
//declaration section
[Code].....
I have a doubly linked list, which reads in a set of coordinates x and y.
I need to pass these coordinates into a method called calculateImportance and execute Pythagoras on them. With this in mind I need to be able to access the pointers current, next and prev.
The issue I am having, is that I am unable to pass the pointers through to the method?
This is the list.h
#include <iostream>
class List {
private:
typedef struct node {
int xCoord;
int yCoord;
float importanceFactor;
[Code] .....
i want to calculate age of a person so then i try to make an algorithm which is used in a function like (i know to use math.h for abs()) double age_calculator( int year, int month, int day);
Code:
double age_calculator( int year, int month, int day);
// p means present(current)
int pyear=(2014-year)*365;
int pmonth=(abs(9-month))*30;
int pday=abs(25-day);
return (pyear+pmonth+pday)/365.0;
how can i use current date, i mean i want to use date of present day instead of 2014,25 and 9. I don't know how i can use date of every day.For instance my function returns 14.74 for the parameters; 2000, 01, 01 (for the current day 25/09/2014)
where are operators defined in C/C++? in headers or compiled code?
looking for the definition of how % modulus is calulated
Question: State the values of each of these int variables after the calculation is performed. Assumed that, when each statement begins executing, all variables have the integer value 5.
a) product *= x++;
b) quotient /= ++x;
What is the answer for a and b?
[URL] ....
My calculation function will not work like i wanted it to. It gives me 0 or a crazy number.
this is the function here:
the entire code is on the link:
double calculations(data&avgs) //Calculates the students grade into a final grade
{
int avg1;
int avg2;
int avg3;
int lab1;
[Code] ....
I'm trying to calculate a series of times from start to end, and find out the duration between them, sum them up and see if they're above a certain value or not, for each particular instance.
My goal is to provide a prepared text file with time tags such as this:
Mon 19-Nov-2012 09:12 Mon 19-Nov-2012 09:34
Wed 21-Nov-2012 13:14Wed 21-Nov-2012 17:11
Fri 07-Dec-2012 15:21Fri 07-Dec-2012 15:26
=============================================
Mon 26-Nov-2012 12:50Tue 27-Nov-2012 15:29
Wed 12-Dec-2012 13:07Wed 12-Dec-2012 14:58
Fri 14-Dec-2012 14:22Fri 14-Dec-2012 14:29
And the program is able to calculate the total time relevant to each instance (instances separated by a line of '=').
Some form of number should somehow identify each instance or something similar and a text file is generated with total time printed for each instance. E.g.
Instance 1: 00h22m + 03h57m + 00h05m = 04h24m
Instance 2: 04h15m + 07h44m + 01h51m + 00h07m = 14h04m
Now I'm currently working on making the logic to calculate time within the ranges I'd like based on several parameters.
Are there any references I can use when it comes to working with strings in order to seek and extract these values in order to work with them? The documentation available on this website, despite being very informative, does not show practical applications of said class and I'm at a loss on how to implement the functionality.
I need to write a program that will give me multiple calculation results.
#include <iostream>
using namespace std;
int main () {
int x = 8;
int y = 7;
[Code] ....
It only calculates the last two numbers: 1 and 0, so therefor it gives me 1.
But i need to calculate x and y each time they are smaller(incremented) by one digit.
Please note that the int calculation formula needs to stay.
I had to write a simple program that prompted the user for various test scores and it would pump out his grade average at the end. I did that with no issue, however, my instructor wants me to add something to the end off the code and I'm not sure how to do that. My code is:
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
string tempType;
float SumTest, MaxTest, TestAve,ProgAve,output;
[Code] ....
And this is what I'm supposed to add, the averages are supposed to have numbers from what the user gave.
***************************
Grade Calculator
Program Average
Test Average
Final Grade
***************************
okay for instance
int x = 4;
double y = 2;
printf("%d", (x / y + 5));
what data type is
(x / y + 5)
??