Thread: plz help me make my assigment more bulletproof

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > p = strchr(data, "\n");
    dwks, means
    Code:
    p = strchr(data, '\n');

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    ...
    printf("\n\n\tA\tSmarties\t%3.2f\t%8.2f\t$%8.2f",A_P,a,sub1=a*A_P);
    ...
    printf("\n\n\n\ttotal pounds =\t%8.2f\tSUBTOTAL\t$%8.2f",
              i=a+b+c+d+e+f+g+h,run=sub1+sub2+sub3+sub4+sub5+sub6+sub7+sub8);
    Excuse me while I go away and puke.

    This printf is unreadable enough without the assignment inside it. Do at least this:
    Code:
    ...
    sub1=a*A_P;
    printf("\n\n\tA\tSmarties\t%3.2f\t%8.2f\t$%8.2f",A_P,a,sub1);
    ...
    run=sub1+sub2+sub3+sub4+sub5+sub6+sub7+sub8;
    i=a+b+c+d+e+f+g+h;
    printf("\n\n\n\ttotal pounds =\t%8.2f\tSUBTOTAL\t$%8.2f", i, run);
    Using single letter variable names is probably not the greatest idea.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [Request] Need Help Plz
    By TylerD in forum Tech Board
    Replies: 4
    Last Post: 01-03-2009, 09:54 AM
  2. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  3. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 01:05 PM
  4. Question about atheists
    By gcn_zelda in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 08-11-2003, 11:50 AM
  5. 'functions' in make?
    By mart_man00 in forum C Programming
    Replies: 1
    Last Post: 06-21-2003, 02:16 PM