Martyr2's Profile User Rating: *****

Reputation: 4189 Guru
Group:
Mentors
Active Posts:
11,930 (4.66 per day)
Joined:
18-April 07
Profile Views:
193,437
Last Active:
User is offline Today, 02:58 PM
Currently:
Offline

Previous Fields

Country:
CA
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
Playstation
Your Car:
Who Cares
Dream Kudos:
0
Expert In:
C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

Latest Visitors

Icon   Martyr2 sings "I'm waking up, I feel it in my bones. Code enough to make my systems 0wN. Welcome to the new age, to the new age."

Posts I've Made

  1. In Topic: Database for travel information

    Posted 20 Apr 2014

    What you are describing is called a GDS. It is what powers booking engines on travel sites etc. The problem is that there is somewhat of a monopoly on this information (I use to work in the Travel industry). To get access to the data in those databases is upwards of tens of thousands of dollars. Then once you front the cash, the systems themselves are quite dated. If you are monopoly, no pressure to keep your systems up to date.

    I am not sure if you will find a free source for all this info, but if you do happen to find the holy grail, drop me a line. I would love to see it.

    :)
  2. In Topic: [Noob] Problem appending strings

    Posted 20 Apr 2014

    Ok I just ran your program against your input file, no changes what so ever and it came out right. So it is not your code, it has to be something with your compiler or development setup. I ran this code against Visual Studio 2012 as an empty project so the code works.

    #include <cstdlib>
    #include <string>
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    int main() {
        string txtline, study_date;
        fstream str ("dicom1.txt");
        int i(0);
        ;
        
        //Getting study_date, located on line 19
        while (i < 18){
            getline (str, txtline);
            i++;
        }
        getline (str, txtline);  //pulling line 19 and putting in a string
                                                   
        study_date = txtline.erase(0,92);    //erasing the first 92 characters
        study_date = study_date.erase(8,1);     //erasing the last character
        cout << study_date << "," << endl;          
        return 0;
    }
    
    


    This above version works as expected.
  3. In Topic: Using a file and while loop

    Posted 20 Apr 2014

    Yeah take out the for loop. You will read from the file, place the value into number and then go into your while loop which will handle evaluating the variable and then reading the next value at the end. To read files take a look here...

    http://www.cplusplus...tutorial/files/

    There is a lot of data here, so don't let it overwhelm you. Just scroll down to the "text files" section. There you will see examples of writing and reading files. Notice the direction of the arrows << for writing and >> for reading into your variable.

    // First read a number
    input >> number;
    
    // Evaluate that number (notice against another number, not a letter)
    // Unless you are looking for the number 120 (because that is what 'x' is as a number)
    
    while (number != -99) {
    
       // Do your evaluations
       switch (number % 2)
       {
           case 0:
              even++;
              if (number == 0)
                 zero++;
              sumEven = sumEven + number; //<--- Notice we don't add 1, we add number
              break;
           case 1:
           case -1:
              odd++;
              sumOdd = sumOdd + number;
       }
    
       // Last thing, read again into number
       input >> number;
    }
    
    


    The code above is for you to experiment with. Enjoy! :)
  4. In Topic: Using a file and while loop

    Posted 20 Apr 2014

    First of all you have an infinite loop in your code there. You set number = 0, but you never actually read your file and put the value from the file into your number variable. So here you have a variable called number which is zero, and stays zero, it will never equal 'x' because you never set number to 'x' anywhere.

    Secondly, I am not sure why you have a for loop inside your while loop. Your while loop should...

    1) Evaluate the value of number to see if it is not 'x'
    2) Enter the switch statement to validate what type of number it is (even, odd, zero etc)
    3) Add the value to each counter (if even, increment even, if odd, increment odd, then add the value to sum)
    4) Lastly read in another number and go back to the top of the while loop to evaluate that number

    :)
  5. In Topic: [Noob] Problem appending strings

    Posted 20 Apr 2014

    Well I have run your first example where you said there was an issue and I haven't been able to replicate it. Next step is to provide us with your text file and tell us what compiler you are using. My guess is that perhaps something is going on with your output screen writing over itself or something rather than your code actually coming up with the wrong value.

    I don't see how the first program, where you show it works, would result in a different outcome in your second program (that doesn't work) just after adding << "," in a cout statement.

My Information

Member Title:
Programming Theoretician
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Vancouver, Canada
Interests:
I love programming and science (almost became a chemist). My favorite languages are C#, Java, Python and PHP. While I am not programming I enjoy movies that feature something medieval (Gladiator, Braveheart etc) or high tech (like Hackers or Swordfish).

I have a diploma in computer science and another in arts and science. My favorite sciences are astronomy, chemistry and geology.

If you have any questions regarding programming, you will find I live and breathe the stuff and should prove an invaluable asset.

Winner of 25 2008-2013 DIC Community Awards including Blog of the Year, Mentor of the Year, DIC Head of the Year, Most helpful Programming Category, Most Helpful in Web Development Category and overall Nicest Member of the year.

You can now catch me on Twitter! Follow me as I talk about technology and specifically programming and answer questions like the best book to learn from or how to organize your code.

http://twitter.com/martyrscry :)
Years Programming:
16
Programming Languages:
C/C++/VC++/C#, VB6/VB.NET, Java, JavaScript, Ruby, HTML/CSS, PHP, ASP/.NET, Python, mIRC Scripting

Contact Information

E-mail:
Private
Website URL:
Website URL  http://www.coderslexicon.com
Facebook:
http://www.facebook.com/coderslexicon
Twitter:
martyrscry

Comments

  • (8 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  1. Photo

    Preacher2012 Icon

    30 Mar 2014 - 18:27
    skilled in java?
  2. Photo

    anmie Icon

    09 Dec 2013 - 09:33
    hey hi martyr2.Can you help me with my post?I am about to reach my deadline.Please help me..Thanks
  3. Photo

    Dogstopper Icon

    05 Dec 2013 - 14:39
    Have a 6-year badge good sir!
  4. Photo

    mostyfriedman Icon

    12 Oct 2013 - 21:07
    I am good, busy as well.
  5. Photo

    Martyr2 Icon

    07 Oct 2013 - 12:16
    Good mosty, you? Been busy lately.
  6. Photo

    mostyfriedman Icon

    07 Oct 2013 - 11:26
    Martyr2 my man, how's it going??
  7. Photo

    ishkabible Icon

    22 Aug 2013 - 15:58
    O ah, didn't even realize it. No prob. much deserved!
  8. Photo

    balloon1 Icon

    18 May 2013 - 14:57
    Hi can you help me with one of my questions!
  9. Photo

    groovmuffn Icon

    24 Apr 2013 - 10:10
    Greetings! Newish coder here. I came across your php histogram equalization code the other day and figured I'd try and draft something similar up in javascript. I feel like my code is sound, though something has to be wrong as the output of the image is black with some faint greens. I'm wondering if I am missing something from your original code. Consider perusing a jsFiddle?
  10. Photo

    Martyr2 Icon

    31 Dec 2012 - 12:48
    Thanks lucky3! Winning these types of things always energizes me to continue my work to help everyone I can here. I am a firm believer that we should always provide more than just a quick answer, but teach as well. :)
  11. Photo

    lucky3 Icon

    31 Dec 2012 - 02:23
    Congratulations for the "Mentor of the Year" 1st place, "Nicest Member of the Year" 1st place, "Most Helpful- Web Development" 1st place, and "DIC Blog of the Year" award 3rd place awards! Really impressive, and well deserved.
  12. Photo

    xwordgrl Icon

    27 Dec 2012 - 14:26
    Martyr2, I’m a reporter for the Wall Street Journal and would like to ask you a question about your post on Code Academy. Please email me at sarah.needleman@wsj.com. Thanks!
  13. Photo

    MsParnel Icon

    16 Sep 2012 - 23:17
    Thank you very much for the project list :).
  14. Photo

    ishkabible Icon

    19 Feb 2012 - 20:19
    "This is Chris's basement!!!"
  15. Photo

    Martyr2 Icon

    19 Feb 2012 - 12:47
    Very very true. echo "THIS IS SPARTA!!!";
  • (8 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »