jimblumberg's Profile User Rating: *****

Reputation: 4565 Guru
Active Posts:
15,270 (7.71 per day)
25-December 09
Profile Views:
Last Active:
User is online 15 minutes ago
Viewing Forum: C and C++

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
Expert In:

Latest Visitors

Icon   jimblumberg has not set their status

Posts I've Made

  1. In Topic: Employee/Department Problem(c)

    Posted 28 May 2015

    Have you tried printing out the values that you are attempting to read from the file to insure you're actually reading the file correctly? Have you fixed the problem with the
    fsanf() call that I mentioned in my earlier post?


    What is wrong with this?

    Why not just use something like:?
    if(strcmp(person[0].department,"DEPA") == 0)

  2. In Topic: Missing The Last Character

    Posted 28 May 2015

    Since you're using a C++ string for z why are you using an array of char for zebra? Why not use a string for this variable as well.

    Have you considered using a stringstream to parse your string into individual words, then use one of the string.find() functions to test if the "search character" is contained within the word?


    for some reason I can't figure out why the last character in the string isn't saving to the new array.

    Probably because of this line:
                while(z.at(j) != ' ' && j != count -1)

    Why are you using count - 1 instead of just count? Since you're using an array or char for zebra you need to also insure that you don't try to copy more than the size of the array can accommodate.

    If you stick with C++ string instead of the character array you can greatly simplify your program and eliminate several sources of potential problems.

  3. In Topic: Employee/Department Problem(c)

    Posted 27 May 2015

    One of the things I see wrong is that you're not using fscanf() properly:

           fscanf(file,"%s %s %f",&person[i].department, &person[i].name, &person[i].salary);

    There are a couple of things wrong here. First never use scanf() to retrieve a string without supplying the correct width specifier to limit the number of characters this function will try to retrieve, this is to eliminate the possibility of a buffer overflow error. Next when dealing with strings you don't need the ampersand, the name of the string is all you need. So it should be something like:

           fscanf(file,"%9s %9s %f", person[i].department, person[i].name, &person[i].salary);

    Notice that the proper width specifier is one less than the size of the array, you need to save room for the end of string character which this function always appends to the string.

    And please stop putting multiple statements on the same line. Tacking that i++; to the end of this fscanf() call will make seeing that statement harder and if you need to debug the program having multiple statements on one line makes detecting some problems much more difficult.


    I wrote a code to check if for example first employees department name is equal to DEPA, DEPB, DEPC OR DEPD. It didn't give me syntax errors but didn't work at the same time.

    Then why don't you post that code and describe what is going wrong. If you hide the code from us we can't see what you're doing correctly or incorrectly.

  4. In Topic: c++ _getch, automate an input

    Posted 27 May 2015

    You need to look up the documentation for that non-standard compiler specific function and see what is actually returned when a "special" key like an arrow key is pressed. I believe it returns more than one value for these special keys. You really should be using the Windows API functions like GetAsyncKeyState() instead this outdated console function.

  5. In Topic: Dynamic allocation is not deleted

    Posted 27 May 2015

    Let's look at your delete function which has several problems:
    	void operator= (const Vector &other) // operator =
    		if (storage != NULL) // if the left side (A=B)/>/>/>/> are not NULL
    			storage = NULL;
    			cout << "******";
    			storage = new T[other.size]; // build new one
    			assert(storage != 0);
    			cout << "new storrange" << storage;
    			size = other.size;// update the size
    		for (int i = 0; i < other.size; i++)
    			storage[i] =other.storage[i];// copy the values 

    Look closely at that if() statement. The first thing you do is assign storage to NULL (which either should be 0 or nullptr), creating a memory leak. Then you try to delete[] memory that doesn't point anywhere. Since the next operation is to allocate a new array, you really don't need the assignment (to nullptr), just delete[] the memory and be done with it. Also note that unless you use the nothrow version of new your assert() is useless, new by default throws an exception if the memory can't be allocated.

    Also what happens if storage is a nullptr when this function is called but has a size that is smaller than other.size()?

    Lastly just because you delete[] the memory doesn't mean that the contents of those memory locations are "erased", the memory is just returned to the operating system.


My Information

Member Title:
Age Unknown
December 6

Contact Information



Page 1 of 1
  1. Photo

    mireille4U Icon

    30 Apr 2015 - 05:26
    Greeting from mireille i saw your profile today and i became interested in you and i will like to know more about you and if you can mail an email to my mail address (mireille4u@live.com) i will give you my picture.here is my mail address i hope we can move from here.above. Mireille
  2. Photo

    modi123_1 Icon

    17 Nov 2014 - 08:11
    I like brocken's comment "I don't know much about coding, but it would be really easy".
    Heh.. I don't know anything about the topic, but I know it is easy.
  3. Photo

    brockenglass101 Icon

    22 Oct 2014 - 02:34
    I know that this isn't what this site is for but many people in the pc gaming comunity have been looking for screen magnification program that would zoom in on the center of the screan rather then the cursor (turned on and off with a hotkey). Now, I am not going to lie, I don't know much about coding, but it would be really easy to make program like this one.
    I hope you will find ...
  4. Photo

    KnifeTea Icon

    11 May 2014 - 05:55
    thanks for the help Jim!
  5. Photo

    tarmizi_adam2005 Icon

    04 Dec 2013 - 07:15
    Just stopping by to say Hello Jim. I've learned quite a few things from your posts in the c/c++ forum.
Page 1 of 1