Karel-Lodewijk's Profile User Rating: -----

Reputation: 451 Architect
Group:
Mentors
Active Posts:
859 (0.63 per day)
Joined:
17-March 11
Profile Views:
7,187
Last Active:
User is offline Yesterday, 03:57 AM
Currently:
Offline

Previous Fields

Country:
BE
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
275
Expert In:
C/C++, Ruby
Icon   Karel-Lodewijk has not set their status

Posts I've Made

  1. In Topic: Reading Binary files in C++ using fstreams

    Posted 11 Dec 2014

    Basically just

    inputFile.read((char*)&width,sizeof(width));
    
    


    If you still have issues provide a test program.
  2. In Topic: clear screen following user input

    Posted 10 Dec 2014

    View Postchimp8471, on 10 December 2014 - 07:35 PM, said:

    In my program i want to ensure the user is only using numbers to data enter in the calculator part if letters or symbols are entered i would like a message to say "invalid entry - please use only numbers"

    How on earth do i do this please...


    A istream object like cin has some internal state flags. What you are looking for is prolly something like.

    cin >> number;
    while (cin.fail()) {
        cin.clear(); //clears state to good or it will stay in the failed state even if the next input is correct
        cout << "try again" << endl;
        cin >> number;
    }
    
    
    
  3. In Topic: linear search algorithm Issue

    Posted 10 Dec 2014

    for (int q=0; q=size2;q++)
    
    


    should prolly be

    for (int q=0; q<size2;q++)
    
    


    or at the very least

    for (int q=0; q==size2;q++)
    
    


    q=size2 is definitely wrong as it is an assignment, not a comparison. It will prolly compile but will assign size2 to q and then evaluate q, which will be false if q==0, otherwise true. I doubt this is what you want.

    int rs=secfunc(array1;size1;array2[q])
    
    


    And how does this even compile ?

    Anyway if you are still having issues after this, give us a working example.
  4. In Topic: Reading the file and show the vector

    Posted 10 Dec 2014

    int numb[3];
    ifstream output;
    output.open("1.dat");
     while(!output.eof())
    {
    output>>numb[3];
    }
    //assuming there are 3 number in vector
    for(int i=0; i<2;i++)
    {
    cout<<numb[i];
    }
    
    


    Your problem is you are trying to put 3 integers in position numb[3], which doesn't even exist. int numb[3], makes an array of 3 integers numb[0], numb[1] and numb[2]. So try something like

    int i = 0;
    while(!output.eof() && i < 3)
    {
    output>>numb[i];
    i++;
    }
    
    


    Notice the i < 3 too. If there are more than 3 numbers in the file we have nowhere to put them so we should probably not continue.
  5. In Topic: Understanding a ray tracer

    Posted 10 Dec 2014

    double post, I'm an idiot.

My Information

Member Title:
D.I.C Addict
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Full Name:
Karel-Lodewijk Verdonck

Contact Information

E-mail:
Click here to e-mail me

Comments

Page 1 of 1
  1. Photo

    raspinudo Icon

    31 May 2012 - 11:41
    Just wanted to say thanks for your C++11 Memory Management Tutorial, it was super helpful; hopefully I can try to use some of the new features in my side project this summer. I did have one question, you mention the 'C way' of allocating, 'malloc'; is there anytime in C++ where it would be better to use malloc instead of new?
  2. Photo

    general07z Icon

    18 Feb 2012 - 22:21
    Thanks a million lats. Keep it up.
    Best Regards and respect
  3. Photo

    Karel-Lodewijk Icon

    05 Feb 2012 - 09:52
    No, sorry, must be someone else.
  4. Photo

    Cyclopses Icon

    31 Jan 2012 - 05:05
    Former math teacher by any chance?
  5. Photo

    ishkabible Icon

    12 Oct 2011 - 18:38
    great job in C++, keep it up!
Page 1 of 1