User Profile

Collapse

Profile Sidebar

Collapse
RRick
RRick
Last Activity: Dec 27 '13, 07:07 AM
Joined: Feb 10 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • The correct use of erase is
    Code:
     iterCString = wStr.erase(0, 1);
    But there are other issues here. When you find a bad wchar, you always erase the first wchar in the string. You probably want to erase the wchar at the iterator position.
    Code:
     iterCString = wStr.erase( iterCString);
    See more | Go to post

    Leave a comment:


  • Replace the return in line 17 with an exit command (i.e. exit 1). Typically, return is only used inside a subroutine. Outside of subroutines, use exit.
    See more | Go to post

    Leave a comment:


  • RRick
    replied to help I have an exm tommorow
    in C
    You need to work out the design yourself, but the above description has broken the problem into its pieces. That's a good place to start.

    If you can use C++, then I suggest you use the STL vector object. It has built in methods for managing elements. There are also STL algorithms for sorting and merging vectors.
    See more | Go to post

    Leave a comment:


  • RRick
    replied to merge two memory (char*) buffers to one
    in C
    Another assumption you are making is that the color is exactly 1 byte long. This might be true for greyscale, but not for color.

    I believe Tiff uses RGB triplets for each color pixel which means you are dealing with 3 bytes, not 1.
    See more | Go to post

    Leave a comment:


  • RRick
    replied to Finding length of Dynamic Array in C/C++
    in C
    That's the problem with using C/C++ arrays. If you want to avoid overflowing or out of bounds elements in the array, you must keep track of the size (i.e. the n value). If this sort of thing seems laborious and dangerous, try the STL vector. It deals with those issues....
    See more | Go to post

    Leave a comment:


  • Did you turn on the compiler debug flag -g (or -g3) flag? Also, if you have stripped out all symbolic info, you won't get any trace info.

    The other problem might be the system you are using. I had problems with cgywin and the debug information. If you are using a "normal" linux distro, this shouldn't be a problem.
    See more | Go to post

    Leave a comment:


  • RRick
    replied to Creating a Template
    in C
    What seems to be the problem?

    Your operator= for TStats seems odd. It looks like it is defined for T rather than TStats.
    See more | Go to post

    Leave a comment:


  • RRick
    replied to Identifying threads in VS .NET 2003
    in C
    Have you tried the debugger with this? I assume VS 2003 knows how to deal with multiple threads and can stop on errors.

    Access violations are caused by bad pointers, typically a null pointer. Since the address is low, the location 0x000001dc might be an offset into a structure or class. If its not too difficult, I would check the class pointer values in your code.
    See more | Go to post

    Leave a comment:


  • RRick
    replied to Project in C
    in C
    Your name for the destination is a directory, not a file. For fopen to work correctly it needs a file name.

    You need to check the FILE * values after you call fopen and make sure they are not 0. That is a failure result from fopen. If you don't check the value and try to use the bad FILE *, your program usually crashes and burns with a seg fault.
    See more | Go to post

    Leave a comment:


  • RRick
    replied to Any way to print out template typename value?
    in C
    This works fine, but the output is not very recognizable. With this format, typeid gives you a name of i for int, j for unsigned int, c for char, and (oh yes) h for unsigned char.

    GNU g++ uses the Itaniium C++ ABI (http://www.codesourcery.com/public/cxx-abi/abi.html). Go past the mangled name section for more info about the encodings.

    It appears to be a format designed to print out any variable defined in the know...
    See more | Go to post

    Leave a comment:


  • RRick
    replied to DLL's, Borland & alot of Frustrations
    in C
    I have worked a little bit with DLLs and found that they have issues with what can cross between the DLL library to your application.

    For example, if something is newed in the DLL, then it needs to be deleted in the DLL. STL containers in the DLL have issues when accessed/modified by your app.

    I'm not sure of the specifics and this was a while ago. Perhaps someone else can clarify these issues.
    See more | Go to post

    Leave a comment:


  • RRick
    replied to Project in C
    in C
    I agree with W4cats that there is a lot of confusion in what you mean by move, copy and paste. For clarity, lets ignore the paste word and use only move and copy.

    Let's look at the command you are trying to mimic in C.


    First of all, move is a special type of command where the file is copied to a new location and original file is deleted. You will have to use some system command to delete the original file....
    See more | Go to post

    Leave a comment:


  • RRick
    replied to GDIplus :: Resizing an Image
    in C
    Was line 33 part of the problem?
    See more | Go to post

    Leave a comment:


  • RRick
    replied to image processing using c
    in C
    You need to ask yourself if you want to manipulate images or if you want to display images. If you want to do both, then openGL is one way to go. OpenGL's main purpose is to create 3D images, but it can also support 2D images.

    If you want to manipulate images and then use some other program/gui to display the results, there are lots of "image processing" packages out there. Windows has its own packages, for example GDI+...
    See more | Go to post

    Leave a comment:


  • Srand is the random number generator that takes a seed value. Passing srand the time value is a good way to start a unique sequence of random numbers. If you want the random number sequence to be repeatable, then use the same integer value as a seed.

    Typically, when creating a string of random numbers, you call srand first with the seed value, and then call rand for all of the rest of the random numbers. Try this link: http://...
    See more | Go to post

    Leave a comment:


  • RRick
    replied to pthread_mutex_unlock() returns 1
    in C
    Actually, EPERM means that the thread does not own the mutex. In particular:...
    See more | Go to post

    Leave a comment:


  • RRick
    started a topic Any way to print out template typename value?
    in C

    Any way to print out template typename value?

    I have a simple template method that looks like
    Code:
        template < typename T>
        void WhatEver( void)
        {
             T t;
             // How to print with cout the T value (not the t value)?
        }
    I thought maybe RTTI would work, but that deals with classes with virtual methods. Since T is most likely going to be an int or double, is there any built in C++ way to print out the value of T...
    See more | Go to post

  • RRick
    replied to GDIplus :: Resizing an Image
    in C
    First of all the pointer at line 33 is not initialized. This looks like its pointing to almost anywhere and I'm surprised it works at all.

    The microsoft web site has some examples of resizing images. This might be a faster way to make the conversion. Take a look at this link: http://msdn.microsoft.com/en-us/libr...86(VS.85).aspx
    See more | Go to post

    Leave a comment:


  • RRick
    replied to malloc array of structs + a little more
    in C
    I'll throw my 2 cents in and notice that count in the switch statement is never incremented. Each time you loop through you will do the same thing over and over (I assume count is initialized to 0) until you run out of tokens from strtok.

    You are also doing something "weird" with the buffer by maintaining an offset paramIndex that you keep increasing. Finally, paramLength is not set until the default case, and who knows...
    See more | Go to post

    Leave a comment:


  • RRick
    replied to sorting a structure...?
    in C
    Your problem is with various comparisons and assignments for the variable called a. They will only work is a[j] is a number, which means the variable a must be an array of ints or some other type of number.

    If a is an array of objects or structs, you have to define how the operators work.
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...