help with structures in c

This is a discussion on help with structures in c within the C Programming forums, part of the General Programming Boards category; Hi, I have a problem with structures in c. In my book is written that I load a structure of ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    2

    help with structures in c

    Hi, I have a problem with structures in c.
    In my book is written that I load a structure of complex number like this:
    typedef struct{double re,im;}compl;
    compl load(compl c){
    scanf("%1f%1f",&c.re,&c.im);
    return c;}.
    But, it does not load in complex number i told him to load. Like this:
    void pisi(kompl a){
    printf("\n%.3f%cj%.3f",a.re, (a.im?'-':'+'),fabs(a.im));}.
    Which function is wrong?
    And, can I define series of complex numbers like : compl series[100];?
    Sorry for my English!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    > scanf("%1f%1f",&c.re,&c.im);
    What about just %f %f

    > And, can I define series of complex numbers like : compl series[100];?
    Yes.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    2
    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Declaring structures inside structures ?
    By jamaican1231 in forum C Programming
    Replies: 6
    Last Post: 04-13-2010, 03:40 PM
  2. Problems with Nested Structures and Arrays of Structures
    By Ignoramus in forum C Programming
    Replies: 4
    Last Post: 03-02-2010, 12:24 AM
  3. Accessing Structures Inside Structures
    By Mellowz in forum C Programming
    Replies: 1
    Last Post: 01-13-2008, 02:55 AM
  4. Structures, passing array of structures to function
    By saahmed in forum C Programming
    Replies: 10
    Last Post: 04-05-2006, 11:06 PM
  5. Replies: 5
    Last Post: 04-11-2002, 11:29 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21