And what if it is standard output? How do I specify "cout" to be binary?
Type: Posts; User: Hardboy
And what if it is standard output? How do I specify "cout" to be binary?
Hi,
Iīve made a program which should output som binary data. The problem is that more bytes than I specify gets out, and somehow the data seems a little corrupt. Itīs only a problem under Windows,...
Havenīt quite read your code, but, you donīt mention what is your problem. Compiler errors? Malfunctions? What?
Iīd like to read in some bytes from a file, but first I need to know the file size. How does one do that in C++?
Just found the serious bug.
Í used logical AND instead of bitwise AND. Resulted in every byte converted to 1...
Thanks, that solved one bug.
The program, though, still doesnīt work correctly. Anymore suggestions?
Hi,
Iīm trying to write a program that does some color conversion, but I cannot get it to work right. It seem that that the compiler doesnīt like conversion between int and double. Hereīs the...
Guess you shouldnīt be making statements in class declaration:
pointer=&h;
Do this in your constructor instead!
Thanks! That solved all my problems.
No, my friend, using & passes it as reference.
Using * passes it as pointer.
Try out this piece of code yourself:
#include <iostream>
using namespace std;
When called, it passes the values, when returning it passes the values!
Itīs like this:
function(type passedbyvalue,type& passedbyreference);
The passedbyreference variable shouldnīt...
That helped! But - yeah - Iīm getting a byte too much... Do you know why, cause I canīt understand this one as well....
Itīs difficult to say. I canīt see anything wrong in your code, but nethier can I see anything usefull...
Should that be like:
in.open(argv[1],ifstream::in|ios::binary);
Or how should I specify it?
Another things is - itīs not just a few bytes short, but it depends much on the file...
Sure! Itīs a program which calculates the entropy of a source. The entropy is a statistic measure, and the calculations are working like they should. The problem is, that when run on window -...
Use your defines!
You have defined TABLE_SIZE but you donīt use it. Do yourself the favor!
Also define like:
#define MAXLINESIZE 256
and replace your magic 256-number with that.
>>>while(in.good()){
>>>data[i++]=in.get(); }
>This is a buffer overflow just waiting to happen.
I know that, but right now itīs only in test phase, Iīll adjust that later.
...
Hi,
Iīve written this program to input some data, and make some calculation on this data. Problem is that I cannot get the input working. Iīve copied the code from another program of mine where...
Is it possible to assign a double to NaN in c++ like:
double number = NaN;
Suggestions welcome...
You seem to know pretty much what you wanna do. Hereīs my advice:
1. Write pseudo
2. Convert to C++
3. Compile and Run
4. Find errors, and if you canīt, then come back here and ask!
Specific...
Does anyone know how to check for overflow in a c program?
like when:
result=var1+var2;
How do I know if an overflow has occured?
Sure I could read the thing into a string, but what I search is a function that will FLUSH unread input. I thought clear(): did that, but it doesnīt... Any suggestions?
Hi!
Iīm trying to fulsh standard input - all though this seems not possible to me. My code is:
bool exit_status;
char current;
exit_status=false;
Some compiler support differenīt syntax for main. Check your compiler documentation - maybe youīll find one which suits you better...
Just got it working!
I needed to write like this:
private:
istream& is;
Intead of: