I would like to write the message to a char* instead of to stdout
void QTUtility::error( char *msg,...)
{
va_list ap;
va_start(ap, msg);
fprintf(stdout, "\n\nERROR: ");
...
Type: Posts; User: markucd
I would like to write the message to a char* instead of to stdout
void QTUtility::error( char *msg,...)
{
va_list ap;
va_start(ap, msg);
fprintf(stdout, "\n\nERROR: ");
...
I have a program that uses alot of vectors. I have tried optimizing it at levels -O and -O2. The performance is much better at -O2. But the results the program gives are different. I have a test...
if I have a vector and I wanted an iterator, I would do something like the following:
vector<int> myVector;
vector<int>::iterator it = myVector.begin();
But if I have a vector of vectors...
No. Sorry, I have just taken bits from the code. In my program the vector that I am resizing is called structMask. I was just trying to illustrate a point. So it would be
vector<char>...
I am using g++ 3.4.2
The code is very long (about 25000 lines) so I cant show it all here :)
The variable prfLength is passed into a function with the following prototype:
void calcGapPenaltyMask(int prfLength,...
Well, I am thinking that maybe some memory problem earlier on is causing this problem. I dont know why else the vector would be resized to over 4 billion. I can see that the number I am actually...
I am having a problem with what I think is a memory leak in my program. I am creating a vector of chars, and then resizing it. I am stepping through the code using the debugger, so I can see that I...
Is there an equivalent to fscanf in c++?
I need to read a float from an ifstream. In C, it would be something like the following:
fscanf(file, "%f", &dist);
In C++, I could use >> maybe....
Does anyone know if it is possible to pass an optional auto_ptr to a function? I want to pass in an auto_ptr to a file handle sometimes, but not others. My code looks like the following
void...
Hi,
I am trying to use setprecision to output at most 5 digits after the decimal point of a floating point number. The problem is that it prints out more than 5 digits if there are zeros. For...
I am using statically allocated arrays, and I am only timing the array access part. The O2 optimization flag worked.
Thanks
Mark
I dont know which optimizations to turn on. I am using the g++ compiler on linux.
Everything I have read recommends using stl vectors instead of c style arrays. But when a ran some tests of 100 million accesses of arrays and vectors, I found that the array part finished in 1...
Hi,
I am reading input from standard input using cin. I want to be able to read in newlines. The problem is that sometimes there is other stuff in the cin buffer that may have been left over. I dont...
That works
The setprecision function only seems to work if the positions are non zero. Is there some other way? Say I have weight = 10, and I want it to be printed as 10.00. Is there a way to do this?
Thanks
...
In C I have done something like the following:
fprintf(parout, "-weight=%2.f", weight);
This will print out weight with 2 decimal places, even if they are both zero. Is there a way to do...
How can I set the number of decimal places when writing to an ofstream? I want to always write 2 decimal places, even if they are both zero.
Thanks
I am currently using the following code to convert a string (or part of it) into an integer:
string myString;
......
int temp = 0;
sscanf(myString.c_str(), "%d", &temp);
The problem was that the file was not being closed in the program.
Hi,
I have a pointer to an ofstream object, and I am trying to use it to write to a file using the << operator, but it wont work. Here is the code I am using:
// in header file
ofstream*...
Hi,
I am trying to pass a pointer to a function that accepts a reference to an object. Can someone tell me how to do this?
My code looks something like the following:
UserMatrix mat;...
How can I use delete to free up the memory in a 2D array? Do I need to call it for each of the rows in the array??
So say if I have
char **args = new char*[argc];
for(int i=0; i < argc;...
Thanks for the reply.