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

Reputation: 4767 Guru
Group:
Mentors
Active Posts:
15,765 (7.05 per day)
Joined:
25-December 09
Profile Views:
82,314
Last Active:
User is online 2 minutes ago
Currently:
Viewing Forum: C and C++

Previous Fields

Country:
US
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
50
Expert In:
C/C++

Latest Visitors

Icon   jimblumberg has not set their status

Posts I've Made

  1. In Topic: Functions

    Posted 9 Feb 2016

    Also you're error numbers don't agree with your code.

    "asn_3.c: In function ‘firstDigit’:
    asn_3.c:58: error: ‘intNum’ redeclared as different kind of symbol
    asn_3.c:55: note: previous definition of ‘intNum’ was here
    

    These error messages are talking about your firstDigit() function, but the line numbers are contained in the comment between firstDigit() and secondDigit().

    Jim
  2. In Topic: Pointers - I don't get them

    Posted 9 Feb 2016

    You may also want to mention the language you happen to be using.

    Jim
  3. In Topic: Weird output after running program?

    Posted 9 Feb 2016

    Have you run the program with your debugger? Set a breakpoint and then single step through the program watching the variables as you step. You are probably trying to access your array out of bounds.

    Jim
  4. In Topic: getting hours minutes and seconds from seconds in c++

    Posted 9 Feb 2016

    This seems to work for me:

    #include <iostream>
    
    using namespace std;
    
    // define constants
    const int SECS_PER_MIN = 60;
    const int SECS_PER_HOUR = 3600;
    
    int getHours(int m_time)
    {
        return (m_time / SECS_PER_HOUR);
    }
    
    int getMinutes(int m_time)
    {
        int hours = (m_time % SECS_PER_HOUR);
    
        return hours / SECS_PER_MIN;
    }
    
    int getSeconds(int m_time)
    {
        return m_time % SECS_PER_MIN;
    }
    
    int main(void)
    {
        int hours = 0;
        int minutes = 76;
        int seconds = 79;
    
    
        std::cout << "Please enter the number of hours: ";
        std::cin >> hours;
        while(hours > 0)
        {
    
            while(minutes > 60)
            {
                std::cout << "Please enter the number of minutes (less than or equal to 60): ";
                std::cin >> minutes;
            }
    
            while(seconds > 60)
            {
                std::cout << "Please enter the number of seconds (less than or equal to 60): ";
                std::cin >> seconds;
            }
    
            int hour_seconds = hours * 3600;
            int minutes_seconds = minutes * 60;
            int total_seconds = hour_seconds + minutes_seconds + seconds;
    
            std::cout << "Total Seconds: " << total_seconds << std::endl;
            std::cout << "Hours:   " << getHours(total_seconds) << std::endl;
            std::cout << "Minutes: " << getMinutes(total_seconds) << std::endl;
            std::cout << "Seconds: " << getSeconds(total_seconds) << std::endl;
    
            std::cout << "Please enter the number of hours (-1 to exit): ";
            std::cin >> hours;
    
        }
    
        return 0;
    }
    
    


    Jim
  5. In Topic: getting hours minutes and seconds from seconds in c++

    Posted 9 Feb 2016

    Well if you would have posted this information in your first post, I may have had a better guess. But since you didn't show anything about m_time it was the best guess I had.

    Now if you would show the smallest possible complete program that illustrates the problem, maybe I can stop guessing.

    My guess now is that your original "combine" function is incorrect.
    take hours =  1 * 3600 = 3600
         min   =  1 *   60 =   60
         sec   = 59 *    1 =   59
                             ----
    
                             3719
    


    Jim

My Information

Member Title:
Age:
Age Unknown
Birthday:
December 6
Gender:

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. 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.
    Riiiiiiiiiight.
  2. 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 ...
  3. Photo

    KnifeTea Icon

    11 May 2014 - 05:55
    thanks for the help Jim!
  4. 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