Thread: someone plz re-structure my head

  1. #1
    Registered User breed's Avatar
    Join Date
    Oct 2001

    someone plz re-structure my head

    I am confused about how to input from the keyboard into a struct
    struct people{
    char name[20];
    int age;
    char sex[10];

    void input_data(struct people *in_str);

    int main()
    {................some code..................}

    void input_data(struct people *in_str)

    printf("Enter name >");
    gets ( //whats the difference between this
    gets(in_str->name)..........// and this i know this
    //is a pointer

    //but now i've come across this on
    printf(" enter name >");
    fseek(stdin, OL, SEEK_SET); //is stdin necessary here
    fgets(, 20, stdin);//and here

    It's gettin a bit confusing and i'm startin to go bald
    Before you judge a man, walk a mile in his
    shoes. After that, who cares.. He's a mile away and you've got
    his shoes.
    ************William Connoly

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    . when accessing the structure directly
    -> when accessing it via a pointer.

    struct mystruct { int x; };
    struct mystruct thisOne;
    struct mystruct *ptrOne;

    ptrOne = thisOne;

    thisOne.x = 10;
    ptrOne->x = 10;


  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    "stdin" stands for "standard input" which is typically coming from the users keyboard. So yes, it is neccessary in using say "fgets()" because fgets() needs to know where to read from.

    Now I've never heard of using fseek() on stdin, but then again, I am still a newbie! But I can say you can probably omit THAT line of code.
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. add/remove a field to structure
    By andone in forum C Programming
    Replies: 2
    Last Post: 03-26-2007, 12:01 AM
  3. structure ...solution plz????
    By hegdeshashi in forum C Programming
    Replies: 4
    Last Post: 07-24-2006, 09:57 AM
  4. Can't figure out problem with code
    By Beast() in forum C Programming
    Replies: 4
    Last Post: 04-16-2005, 05:27 PM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM