Thread: Call for an exit in C

  1. #16
    Registered User litebread's Avatar
    Join Date
    Dec 2011
    Location
    California
    Posts
    21
    Quote Originally Posted by inu11byte View Post
    Just a few little tips.
    1. fflush(stdin); is bad. Cprogramming.com FAQ > Why fflush(stdin) is wrong
    2. Use fgets() for getting strings. C Strings - Cprogramming.com

    Good luck with your program.
    Yep know all that, but wont bother with it for now. I need to fix the output first...

  2. #17
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by litebread View Post
    Yep know all that, but wont bother with it for now. I need to fix the output first...
    One sure way to lose people's help real fast is to blow off their suggestions...

    Good luck with your code... I'm outa this one.

  3. #18
    Registered User litebread's Avatar
    Join Date
    Dec 2011
    Location
    California
    Posts
    21
    I'm sorry i didn't mean to just blow it of. I meant it's not breaking the code as far as I've checked. I was simply asking if you knew the source of the problem for the output, but honestly I didn't mean to undermine your suggestion. I have remembered your suggestion and will take the time to read on the subjects you provided, but if it's not breaking the code I simply don't have the time to study why gets() and fflush is bad.

    Pardon me I just want to get the critical errors fixed before I go into fflush and gets. I was thought all year that they work and they have so I see no reason as of this particular moment to focus my and your time on such a trivial error (Unless you believe otherwise, in which case I have already stated that I will research as to what problems both of those statements can cause).

    Now I don't want to be anymore of a douche, so I simply ask if you could help me find the source of the error, which is the bugged output from file (Assignment requires for me to save the data to file, load and print it.)

  4. #19
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by litebread View Post
    I'm sorry i didn't mean to just blow it of. I meant it's not breaking the code as far as I've checked. I was simply asking if you knew the source of the problem for the output, but honestly I didn't mean to undermine your suggestion. I have remembered your suggestion and will take the time to read on the subjects you provided, but if it's not breaking the code I simply don't have the time to study why gets() and fflush is bad.

    Pardon me I just want to get the critical errors fixed before I go into fflush and gets. I was thought all year that they work and they have so I see no reason as of this particular moment to focus my and your time on such a trivial error (Unless you believe otherwise, in which case I have already stated that I will research as to what problems both of those statements can cause).
    Well for one thing... look at your struct... if you enter too much text at the fgets() call it's going to overwrite the rest of your struct, so it's entirely possible that's been your problem --as we've been telling you-- right from the start.

    Straight up... given the structure of your program, which looks more like someone playing than anything else, your use of deprecated functions and the pointless inclusion of irrelevant code... my grade to you would be an F.
    Last edited by CommonTater; 12-10-2011 at 07:56 PM.

  5. #20
    Registered User litebread's Avatar
    Join Date
    Dec 2011
    Location
    California
    Posts
    21
    Quote Originally Posted by CommonTater View Post
    Well for one thing... look at your struct... if you enter too much text at the fgets() call it's going to overwrite the rest of your struct, so it's entirely possible that's been your problem --as we've been telling you-- right from the start.

    Straight up... given the structure of your program, which looks more like someone playing than anything else, your use of deprecated functions and the pointless inclusion of irrelevant code... my grade to you would be an F.
    Wow. Umm. I really have not much to say. Thanks for the advice. I don't know who you are, or how good of a programmer you are, but I'm a 19 y.o. dude who's just finishing up his first class in programming, so pardon my "using of deprecated functions" and "pointless inclusions". I write code neatly and make it fun, but since you are so kind to have given me such a low grade it seems like you are a dull and a sad programmer.

    I just asked if you could find a solution where I have failed, not criticize me and my code for my lack of knowledge. Oh and did I ask for a letter grade? No. So if you would like to be a teacher you can do that elsewhere. I came for advice for a specific question. If you are so kind to have provide it (Which I believe you have, at least slightly), I would be in great debt.

    So far I have received "pointless" criticism and no clear statement as to what line of code is causing this:

    Code:
    Hello, DaveEnter the Stock Name
    >Clippers
    Enter the Number of Shares
    >150
    Enter the Buying Price Per Share
    >1.33
    Enter the Current Price Per Share
    >3.33
    Enter the Yearly Fees
    >5.00
    Enter the Stock Name
    >Spurs
    Enter the Number of Shares
    >215
    Enter the Buying Price Per Share
    >15.77
    Enter the Current Price Per Share
    >14.25
    Enter the Yearly Fees
    >3.50
    
    
    The stock is Clippers
            With Initial cost of $199.50
                    Current cost is $499.50
                            And your Profit is $295.00
    
    
    
    
    The stock is Spurs
            With Initial cost of $3390.55
                    Current cost is $3063.75
                            And your Profit is $-330.30
    
    
    
    
    1 of stocks broke Positive
            1 of stocks broke Negative
                    0 of stocks broke Even
    
    
    The Total Trofit is $-35.300049
    
    
    
    
    The stock is Clippers
    
    
            With Initial cost of $0.00
                    Current cost is $-1.#J
                            And your Profit is $-1.#J
    
    
    
    
    The stock is
    
    
            With Initial cost of $3390.55
                    Current cost is $3063.75
                            And your Profit is $-330.30
    
    
    
    
    The stock is Clippers
    
    
            With Initial cost of $0.00
                    Current cost is $-1.#J
                            And your Profit is $-1.#J
    
    
    
    
    The stock is
    
    
            With Initial cost of $3390.55
                    Current cost is $3063.75
                            And your Profit is $-330.30
    
    
    Press any key to continue . . .

  6. #21
    Registered User litebread's Avatar
    Join Date
    Dec 2011
    Location
    California
    Posts
    21
    Quote Originally Posted by CommonTater View Post
    Well for one thing... look at your struct... if you enter too much text at the fgets() call it's going to overwrite the rest of your struct, so it's entirely possible that's been your problem --as we've been telling you-- right from the start.

    Straight up... given the structure of your program, which looks more like someone playing than anything else, your use of deprecated functions and the pointless inclusion of irrelevant code... my grade to you would be an F.
    Oh I see your 60. Figures.
    Ya man, I'll take my questions and bull........ elsewhere. I didn't know these forums were for retired programmers......

  7. #22
    Registered User
    Join Date
    Jul 2011
    Posts
    25
    His criticism isn't unwarranted. Tater is pointing out things in your code that are likely to cause an error and asking you to fix them. It could very well be the case that the problem resides in the use of these functions. If you're still getting those problems with everything else fixed, then it's at least narrowed down the possible causes quite a bit.

    I'm not on a machine that has VS so I can't test it myself to see if any errors I get is consistent with yours, but look into the problem(s) and try to build on that.

    As far as general logic goes, you also don't need to pass SIZE into each function. It's globally defined, so you can just increment your loops to SIZE without assigning an integer to it. Although it accomplished the same thing, I think it's a little more clear to somebody who's never seen the code before. There's some other things could be done differently, but overall I'd say the structure is pretty acceptable as an assignment. And check line line 113, there's a misspelling there (don't know if your teacher marks off for that stuff, but mine does so head's up).

  8. #23
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Amberlampz View Post
    His criticism isn't unwarranted. Tater is pointing out things in your code that are likely to cause an error and asking you to fix them.
    Except that right about the time they start arguing or ignoring suggestions, you know fully well you can't help them anymore.

    Then of course they get ticked that you're no longer at their beck and call... Having somehow assumed an entitlement to your services.

  9. #24
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by litebread View Post
    My teacher? Ha!
    We're talking about a dude who explains the NULL char by running into a door.
    Now I understand why he never explained why gets() is wrong...

  10. #25
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by manasij7479 View Post
    Now I understand why he never explained why gets() is wrong...
    How would he do that... by running out of the building into traffic?

  11. #26
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by CommonTater View Post
    How would he do that... by running out of the building into traffic?
    Just for showing that it isn't dangerous at all...

  12. #27
    Registered User litebread's Avatar
    Join Date
    Dec 2011
    Location
    California
    Posts
    21
    Do you guys really think that gets() and all the stuff you told me about can break up the output?

    Tater I didn't entitle you or anyone to anything. If you don't want to help, fine. I am just upset that you are simply criticizing my lack of knowledge without much help. You've told me what to look into, but you never clearly stated how to fix the problem. It all sort of "Try this, fix that", but how? Anyways, I'm going to ask my classmates and the teacher tomorrow in class.

    Thanks for the help guys. I'll be sure to bring up all the issues you pointed out to my teacher.

  13. #28
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by litebread View Post
    Do you guys really think that gets() and all the stuff you told me about can break up the output?
    In a word... "Yes". It is very likely the use of these known to be bad functions is part of your problem.

    Tater I didn't entitle you or anyone to anything. If you don't want to help, fine. I am just upset that you are simply criticizing my lack of knowledge without much help. You've told me what to look into, but you never clearly stated how to fix the problem. It all sort of "Try this, fix that", but how? Anyways, I'm going to ask my classmates and the teacher tomorrow in class.

    Thanks for the help guys. I'll be sure to bring up all the issues you pointed out to my teacher.
    1) I and others have given you a ton of good advice that you *stupidly* chose to ignore.
    2) Nobody is criticising your lack of knowledge... only your complete unwillingness to learn.
    3) If you're teacher is as stupid as you say... well, good luck with that. (Maybe you deserve eachother)
    Last edited by CommonTater; 12-11-2011 at 04:58 PM.

  14. #29
    Registered User litebread's Avatar
    Join Date
    Dec 2011
    Location
    California
    Posts
    21
    Quote Originally Posted by CommonTater View Post
    In a word... "Yes". It is very likely the use of these known to be bad functions is part of your problem.



    1) I and others have given you a ton of good advice that you *stupidly* chose to ignore.
    2) Nobody is criticising your lack of knowledge... only your complete unwillingness to learn.
    3) If you're teacher is as stupid as you say... well, good luck with that. (Maybe you deserve eachother)
    Ya I'm out of here......

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help!! call-by-reference and call-by-value
    By geoffr0 in forum C Programming
    Replies: 14
    Last Post: 04-01-2009, 07:15 PM
  2. C system call and library call
    By Coconut in forum C Programming
    Replies: 6
    Last Post: 08-22-2002, 11:20 AM
  3. System call to call another C file from Existing C File
    By simly01 in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2002, 01:29 PM
  4. Call-by-value Vs. Call-by-reference
    By Wiz_Nil in forum C++ Programming
    Replies: 3
    Last Post: 02-20-2002, 09:06 AM
  5. call by reference and a call by value
    By IceCold in forum C Programming
    Replies: 4
    Last Post: 09-08-2001, 05:06 PM