Search:

Type: Posts; User: markucd

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    2
    Views
    1,703

    write to a char* instead of stdout

    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: ");
    ...
  2. Replies
    4
    Views
    2,107

    optimization flags

    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...
  3. Replies
    7
    Views
    1,042

    iterators into vector of vector??

    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...
  4. Thread: memory leak

    by markucd
    Replies
    14
    Views
    2,316

    No. Sorry, I have just taken bits from the code....

    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>...
  5. Thread: memory leak

    by markucd
    Replies
    14
    Views
    2,316

    I am using g++ 3.4.2

    I am using g++ 3.4.2
  6. Thread: memory leak

    by markucd
    Replies
    14
    Views
    2,316

    The code is very long (about 25000 lines) so I...

    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,...
  7. Thread: memory leak

    by markucd
    Replies
    14
    Views
    2,316

    Well, I am thinking that maybe some memory...

    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...
  8. Thread: memory leak

    by markucd
    Replies
    14
    Views
    2,316

    memory leak

    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...
  9. Replies
    5
    Views
    7,679

    C++ fscanf equivalent?

    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....
  10. Replies
    2
    Views
    1,443

    Passing optional auto_ptr to function

    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...
  11. Replies
    1
    Views
    950

    help with iomanip

    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...
  12. Replies
    6
    Views
    1,795

    I am using statically allocated arrays, and I am...

    I am using statically allocated arrays, and I am only timing the array access part. The O2 optimization flag worked.
    Thanks
    Mark
  13. Replies
    6
    Views
    1,795

    I dont know which optimizations to turn on. I am...

    I dont know which optimizations to turn on. I am using the g++ compiler on linux.
  14. Replies
    6
    Views
    1,795

    vectors vs c style arrays

    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...
  15. Replies
    2
    Views
    1,124

    problem with cin

    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...
  16. Replies
    5
    Views
    1,935

    Thanks!

    That works
  17. Replies
    5
    Views
    1,935

    Doesnt seem to work!

    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
    ...
  18. Replies
    5
    Views
    1,935

    In C I have done something like the following: ...

    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...
  19. Replies
    5
    Views
    1,935

    Setting precision?

    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
  20. Replies
    11
    Views
    6,179

    Convert C++ string to int

    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);
  21. Replies
    5
    Views
    858

    Thanks

    The problem was that the file was not being closed in the program.
  22. Replies
    5
    Views
    858

    using

    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*...
  23. Replies
    3
    Views
    1,858

    Pass pointer to function

    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;...
  24. Thread: using delete

    by markucd
    Replies
    2
    Views
    889

    using delete

    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;...
  25. Replies
    4
    Views
    1,287

    Thanks

    Thanks for the reply.
Results 1 to 25 of 38
Page 1 of 2 1 2