Thread: Im 50 but like to know more about this world of you guys need help

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    7

    Cool Im 50 but like to know more about this world of you guys need help

    Hello Friends,
    I need help here, I am unemployed so I have to go back to school and I like to know about website so I took one and so I am also taking C yeheey. This is my assignment number 3 I passed the 1 and 2 but this one is also easy but I still need help.

    #include <stdio.h>
    #include <stdlib.h>
    #define MAX_NAME 30
    #define TITLE "Mabuhay Video Store"
    int main(void)
    {

    char name[MAX_NAME + 1];
    int choice;
    do
    {

    system ("cls");
    printf("=============================\n");
    printf(" %s\n", TITLE);
    printf("=============================\n\n");
    printf("1 Enter Customer Information\n");
    printf("2 Enter Rental Information\n");
    printf("3 Compute Charges\n");
    printf("4 Dispaly Receipt\n");
    printf("5 Exit Program\n\n");
    printf(" Selection: ");
    scanf("%d",&choice);
    getchar();
    if(choice==1)
    {
    getcustomer();
    }
    else if(choice==2)
    {
    }
    else if(choice==3)
    {

    }
    else if(choice==4)
    {

    }
    else
    {
    break;

    }

    }while(choice!=5);

    return EXIT_SUCCESS;
    }

    The above execute good
    Now the next one is Giving me a headache:

    void getcustomer(void)
    {

    system("cls");

    printf("Store Name:\n\n");
    printf("Customer Name:");
    printf( "Address:");
    printf( "City/State/Zip:\n\n");
    printf("Coupon Presented (Y/N): Y");

    return EXIT_SUCCESS;
    }

    I tried to input information about the customer name address and coupon but it won't compile.
    and I have to place the video title and compute charges. I am getting no where.

    This is my assignment, If anyone can help thank you and if someone is going to Bully me thank you also but i hope you do understand that you also been like me. So I need help.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >you never used scanf anywhere... ???
    This is a good thing, scanf should be avoided.

    >I tried to input information about the customer name address and coupon but it won't compile.
    Start by inputting the name successfully, then move on to the other items. If you find your program doesn't work then break it up into several smaller programs to try and find out why. Nothing is more informative than writing a test program for something you don't understand. This code will start you off and compiles just fine:
    Code:
    #include <stdio.h> 
    #include <stdlib.h>
    
    #define MAX_NAME 30 
    #define TITLE "Mabuhay Video Store"
    
    void getcustomer(char *name);
    
    int main(void) 
    { 
      char name[MAX_NAME + 1];
      int choice; 
      do 
      { 
        system ("cls"); 
        printf("=============================\n"); 
        printf(" %s\n", TITLE); 
        printf("=============================\n\n"); 
        printf("1 Enter Customer Information\n"); 
        printf("2 Enter Rental Information\n"); 
        printf("3 Compute Charges\n"); 
        printf("4 Dispaly Receipt\n"); 
        printf("5 Exit Program\n\n"); 
        printf(" Selection: "); 
        scanf("%d",&choice); 
        getchar(); 
        if(choice==1) 
        { 
          getcustomer(name); 
        } 
        else if(choice==2) 
        {
          /* Placeholder */
        } 
        else if(choice==3) 
        {
          /* Placeholder */
        } 
        else if(choice==4) 
        {
          /* Placeholder */
        } 
        else 
        {
          break;
        } 
      }while(choice!=5);
      
      return EXIT_SUCCESS; 
    } 
    
    void getcustomer(char *name) 
    {
      system("cls"); 
    
      printf("Store Name:\n\n"); 
      printf("Customer Name: ");
      /*
      ** fgets reads one line of input, stopping at either 
      ** the second argument, or when the return key is pressed.
      */
      fgets(name, MAX_NAME + 1, stdin);
    }
    Note that this code can be problematic, but those situations are safe to ignore at this point in your learning. I know that this isn't quite the answer you wanted, but sometimes working through a problem simply by studying your code and reading books until your eyes bleed is the best way to learn. Just keep at it and if you get really stuck somewhere, either come to us or your instructor. The thing to remember is that you are continually learning with every bit of this you work on, especially if it doesn't work.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    huh

    Originally posted by Prelude
    >you never used scanf anywhere... ???
    This is a good thing, scanf should be avoided.
    -Prelude
    scanf should be avoided... but not totally..
    there were just a bunch of printfs in the code...
    and input was accidentally forgotten...
    that's the reason why i said scanf ..

    it's only the 3rd assignment... fgets is probably not
    introduced so soon.

    oh and by the way, I already got a PM.. looks
    like the problem is solved..

    people like you can go on whining about things that
    others say/do ... but never learn to be humble/polite..
    you are a great expert in c/c++ .. i understand.... but
    you got to grow up in life and stop whining about every
    little thing on this earth just trying to prove things so
    trifle like "i've got less hair in my armpits than you do"
    (phhh... really funny example here.. )

    >but sometimes working through a problem simply by studying >your code and reading books until your eyes bleed is the best >way to learn

    I wouldn't recommend any sane person to read till their eyes
    bleed. it's not the best way to learn. the best way to learn
    is to work hard (practicing/researching), but with atleast some
    consideration to hygiene.

    this applies to someone...
    humbleness & politeness are virtues. some people think they are too good to understand/follow them.
    Last edited by moonwalker; 07-28-2002 at 11:12 PM.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I rather enjoy Preludes explanation, if not just because it was good advice /*wipes blood from eyes*/...

    Seriously, though, scanf() is unreliable. Use fgets() and until you have mastered string parsing, accept to the slower input method.

    From my viewpoint, there is no reason to take it too easy. Programming requires a lot of effort and attention, and one must constantly maintain momentum lest they fall off the deep end of mediocrity and insipidness...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    .... and what good would scanf() be for getting a name and address? As this function delimits it's input for strings by white space, entering a name of ...
    >Fred Bloggs
    ... will only confuse the program, and probably a new programmer.
    fgets() is far simpler to work with to read a simple string, and does a much better job.

    >people like you can go on whining about things that others say/do
    Do you mean Prelude provides answers to people questions?! Whining doesn't come into it. If people are doing wrong, then it's up to more experience people to point out these errors. That's one of the main points of posting your code here.

    >but never learn to be humble/polite
    so should I start my post with "Please sir, may I help fix your code?"! The answer given was precise and to the point, without being rude. Where's the problem? I don't see one.

    >you got to grow up in life and stop whining about every
    little thing on this earth just trying to prove things
    This again goes back to correcting peoples mistakes. If you say something that isn't correct, you must be prepared to get corrected.

    Maybe I misunderstand your reply, maybe you weren't being serious. It's hard to tell when all I see are your words.

    Anyway... I'm politely saying goodbye now...
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >people like you can go on whining about things that others say/do ... but never learn to be humble/polite..
    I'm sorry if I'm confused, but this makes no sense. How you can mistake a technical correction for whining is beyond me, and I don't recall being rude in my post.

    >I wouldn't recommend any sane person to read till their eyes bleed.
    Nor would I. You probably missed the fact that I was exaggerating on the bleeding part. I meant study the code and read books until you understand better.

    If you have a problem with me, then please keep your insults to private messages. If you have a problem with the technical aspects of any of my posts then feel free to correct me in a civil manner. A good rule of thumb is to speak up you have a suggestion for improvement and if all you can do is resort to flaming then stay quiet. Otherwise I'll assume you are a troll and treat you accordingly.

    -Prelude
    My best code is written with the delete key.

  7. #7
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    huh

    your assumptions already made you an ass.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. allegro problem : /
    By bada in forum Game Programming
    Replies: 4
    Last Post: 03-30-2008, 10:08 AM
  2. New terrain engine
    By VirtualAce in forum Game Programming
    Replies: 16
    Last Post: 03-16-2006, 02:47 AM
  3. Wierd Segmentation Faults on Global Variable
    By cbranje in forum C Programming
    Replies: 6
    Last Post: 02-19-2005, 12:25 PM
  4. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  5. OpenGL coordinates
    By Da-Nuka in forum Game Programming
    Replies: 5
    Last Post: 01-10-2005, 11:26 AM