Thread: Help of C "Hopefully I will get nice Communication from some Admins"

  1. #1
    Registered User kitymarine's Avatar
    Join Date
    Jun 2011
    Posts
    18

    Help of C "Hopefully I will get nice Communication from some Admins"

    I dont know why the admin closed my thread but it is a polite way of communication..Secondly Instead of jumping and accuse me of dumping my assignment I was out of connection yesterday and I could not post my code...For better communication I hope from the Oe Called Salem to be more formal until he will know what people are posting..and this is my tag
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #define nmax 10
    
    
    
    main()
    {
    
    typedef struct Person
    {
    
    char name[30];
    char adresse[30];
    char city[30];
    char state[30];
    int zip;
    int age;
    char gender;
    
    };
    struct Person people[nmax];
    int i;
    for(i=0;i<nmax;i++)
    { printf("Enter the information for the person number : %d\n ",i+1);
    printf("Enter name: ");
    scanf("%s",people[i].name);
    printf("Enter street adresse : ");
    scanf("%s",people[i].adresse);
    printf("Enter city : ");
    scanf("%s",people[i].city);
    printf("Enter state : ");
    scanf("%s",people[i].state);
    printf("Enter zip code : ");
    scanf("%d",&people[i].zip);
    printf("Enter age : ");
    scanf("%d",&people[i].age);
    printf("Enter gender(M or F) : ");
    scanf("%s",&people[i].gender);
    printf("\n\n");
    }
    
    system("PAUSE");
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You forgot to ask a question. What seems to be the problem?

    1. Indent.
    2. int main( void ) instead of "main()", also return 0; at the end of main.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User kitymarine's Avatar
    Join Date
    Jun 2011
    Posts
    18
    yesterday I posted the Question and they closed my thread because I did not post the code due to disconnection..Now I found my question in another Thread..Any ways the question from my assignment is :Write a C program that prompts the user to enter some information about up to ten individuals. (Think of a way to prompt the user) It should store this information in a structure. The program should obtain the information from the structure, and output it as shown in sample run below.

    Your program should include a structure with a tag name of: info. It should contain the following data as members:

    a character array to store person's name, defined as: name[30]
    a character array to store person's street address, defined as: address[30]
    a character array to store person's city, defined as: city[20]
    a character array to store person's state, defined as: state[3]
    a long integer variable to store person's zip code, defined as: zip
    an integer variable to store person's age, defined as: age
    a character variable to store person's gender, defined as: gender

    You need to define an array of type: struct info. You can call this array: people[10].

    The dialog with the user must be as follows:


    Whatever Title you want Here including a
    “How many prompt” etc.

    Enter name: Minnie Mouse
    Enter street address: 100 Disney Drive
    Enter city: Orlando
    Enter state: FL
    Enter zip code: 99990
    Enter age: 25
    Enter gender (M or F): F

    Enter name: Big Bird
    Enter street address: 10 Sesame Street
    Enter city: Funtown
    Enter state: MA
    Enter zip code: 01222
    Enter age: 20
    Enter gender (M or F): M

    The information you entered is:

    Minnie Mouse
    100 Disney Drive
    Orlando, FL 99990
    She is 25 years old.

    Big Bird
    10 Sesame Street
    Funtown, MA 01222
    He is 20 years old.

    Note: The coral text represents the "output" from your program and is shown for clarity only here. It is not required that your output be in this color. (Do not even attempt to try!). Also note that what the user types in is indicated by the blue area above. Again, for clarity only.

    Hints/other requirements:
    Use gets (or safer_gets() ) instead of scanf and printf

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Once again, what's your question? I see your program description, and I see your program code. What is your question to us?


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Just for your own information: I'm fairly new to these forums, but over the last few days I've scoured the the old posts all the way back to February.

    If this were an isolated incident, I could understand how you would be offended. But understand that people frequently come here and "dump" their assignments without offering anything in the way of showing initiative on their part. Even if you didn't mean to do this, it happens very frequently on this board, so after a while I imagine that the admins grow tired of it. I'm sure they do not have the time, interest, or responsibility to find out how "genuine" a poster is. If it looks like someone is "assignment dumping," based on experience, they probably are.

    That is why they have big links saying "read this before you post!" So we can avoid such confusion and misunderstandings.

    I apologize for this aside; please continue.

  6. #6
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Use gets (or safer_gets() ) instead of scanf and printf
    While we're waiting, you should heed this hint. scanf() stops reading input when it encounters certain characters, one of them being a "space."

  7. #7
    Registered User kitymarine's Avatar
    Join Date
    Jun 2011
    Posts
    18
    @Matticus I do Understand your points , just being frustrated by a lot of things ..Also in this question ..I have no clue how to prompt because he posted a lot of hints Im trying to use the scanf for now

  8. #8
    Registered User kitymarine's Avatar
    Join Date
    Jun 2011
    Posts
    18
    Indeed I have no clue how to use the"gets"

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    It's a bit difficult to figure out why you say "I have no clue how to prompt" when you have code like
    Code:
    printf("Enter name: ");
    printf("Enter street adresse : ");
    printf("Enter city : ");
    printf("Enter state : ");
    printf("Enter zip code : ");
    printf("Enter age : ");
    printf("Enter gender(M or F) : ");
    What's wrong with that?

  10. #10
    Registered User kitymarine's Avatar
    Join Date
    Jun 2011
    Posts
    18
    I have put this line"gets("Enter street adresse %s: ",people[i].adresse);" but it does not work

  11. #11
    Registered User kitymarine's Avatar
    Join Date
    Jun 2011
    Posts
    18
    I should use "gets" and get the prompt because the program does not stop

  12. #12
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You should never use gets. Even if for some reason your instructor thinks you should, gets does not do the prompting -- you have to do the prompting.

  13. #13
    Registered User kitymarine's Avatar
    Join Date
    Jun 2011
    Posts
    18
    @tabstop try to run the code and u will see the output different from what required in the assignment

  14. #14
    Registered User kitymarine's Avatar
    Join Date
    Jun 2011
    Posts
    18
    @tabstop believe the instructor is really peaky and takes points off just for less idents ..Whatever he required in the instructions should be done or he will give Big Zero

  15. #15
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You misspelled address, and you have the word typedef when you shouldn't.

    EDIT: Also, you need to move your struct definition before "main".

    EDIT: I meant to say, and then accidentally erased, that if you are not allowed printf you can't[*] actually do the assignment, since puts will print a newline at the end of a string and gets doesn't do any printing. Maybe your instructor's safer_gets does do printing, I don't know.
    [*]Of course, it is actually possible, but you will have to print a single character at a time, with no strings, which is essentially the same thing as not being able to do it.
    Last edited by tabstop; 06-21-2011 at 08:03 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 03-31-2009, 04:23 PM
  2. Replies: 46
    Last Post: 08-24-2007, 04:52 PM
  3. Replies: 12
    Last Post: 08-05-2003, 02:16 PM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM