Writing histogramm

Hello guys,
I tried several times to write a code for historgramm, but it does not compile.
I woulkd be so glad and thanxful, if someone could help me out :).
Thx
Best regards
Amber

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

# include <stdlib.h>
#include <fstream>
#include <vector>
#include <iostream>


using namespace std;

int main (){
	ofstream out ("out.raw",ios_base::binary);
	unsigned char randomnumber;
	for (int i=0; i<255;i++)
	{
		randomnumber=rand()%255;
		out.write ((char*)&randomnumber,1);
		
	}
	vector <int>number (256);
	for (int b=0; b< 256;b++)
	{
		//char in;
		//ifstream in("in.raw",ios_base::binary);
		in.read ((char*)& randomnumber,1);
		zahl[randomnumber]++;
	}
	int summ=0;
	for(int b=0; b<256; b++)
	{
		cout<<b<<":"<<number[b]<<"\n";
		summe=summ+number[b];
	}
	cout<<summ;
	return 0;
	}.
Line 23: you commented out the ifstream, therefore it is undefined on line 24.

Line 25: Where is zahl declared? You have no such array.





Last edited on
... it does not compile.

When the compiler encounters a syntax error in the code, it does more than just stop. It does write out an error message that explains where and what it cannot process. It can also give warnings about code that does compile, but could contain logical error.

It is a very useful skill to understand those messages, because with their help one can usually correct the code.

Different compilers use different error messages. Therefore, you should post the errors that your compiler gives along with the code. Then we can help you to see the correlation.
Last edited on
Topic archived. No new replies allowed.