so i am learning files in class. i was to open a file manipulate the content and create a new file with the manipulate content. spent days on this program and when i run it it creates the new file but with the same content so i end up with two identical files. can anyone spot were i went wrong?
The program appears reasonably valid. Either the particular "manipulations" done have no effect, or the data in the input file is not suitable. It's possible that a different input file would give a more interesting result.
so i tried it using simpler numbers and i noticed that a change was happening but only on the tenth number and the other 99 remained the same. i miss the good old days of physics and calculus when things made sense to me=/
void norm1(int max[], constint size){
int *mx = max;
int maxwave = 0;
int delta;
int wave;
for(int k = 0; k < size; k++){
if(mx[k] > maxwave){
maxwave = mx[k];
wave = k;
}
}
delta = 32767 - maxwave;
maxwave = maxwave + delta;
mx[wave] = maxwave;
comp1(mx, size);
}
This finds the largest number in the array and changes it. If your numbers are sorted, that's likely to be the last element of the array. That's all it changes -- 1 value.
This looks for values over 25000 in the array. It ignores all other values, so if the numbers in your file are 25000 or under, they won't be modified here - remember only one value has been adjusted when this function is entered.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void newnorm(int norm2[], constint size){
int *n2 = norm2;
int maxwave = 0;
int delta;
int wave;
for(int k = 0; k < size; k++){
if(n2[k] > maxwave){
maxwave = n2[k];
wave = k;
}
}
delta = 32767 - maxwave;
maxwave = maxwave + delta;
n2[wave] = maxwave;
created(norm2, size);
}
This looks for the maximum number in the array again and changes it. If there weren't any numbers in the file greater than 25000, I'd say there's a good chance it will modify the same value it did previously.
My apologies. I am new to this website and I did not want to come off as just trying to get my homework done for me. Still thanks for your time and consideration in my question.