Thread: program review

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    1

    Post program review

    Thru this website I did away with empty constants, but i need someone to review this program and offer some insight. Run does not give the expected response.
    Code:
    #include <stdlib.h>
    #include <stdio.h>
    
    #define MAXCHARS 20
    void seperate(char *, char*, int*);
    int main()
    {
        char date[MAXCHARS];
        char tempmonth[MAXCHARS];
        int tempday;
    
        printf("\nPlease enter month and day(for example, June 14):");
        gets(date);
        seperate(date,tempmonth,&tempday);
        printf("\nSeperated date: %d\n",tempday);
        printf("\nSeperated month: %d\n",tempmonth);
    
        system("PAUSE");
    
        return 0;
    }
            void seperate(char*date, char*month, int*day)
    {
        int index;
    
        for(index=0; date[index] != '\0'; index++)
        {
            month[index]=date[index];
        }
        month[index]='\0';
    
        *day = atoi(date+index);
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    This thread was split from empty character constant ?? so that the latter may rest in peace.

    melestorm, is this program supposed to be written in C or C++?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  4. review my telephone network simulation program
    By debuger2004 in forum C Programming
    Replies: 3
    Last Post: 06-20-2003, 01:26 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM