Thread: Number parameters loop

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    4

    Number parameters loop

    I keep getting a stack error with my code. I'm trying to get it to check to see if an entered number is between 0 and 100. I'm new at this, and maybe I'm overlooking something, but help would be nice. I need this for a cool program that lets you set your CPU fan's speed in percent. I also want it to say something when its not a correct entry, then loop back to the top for input again. Like I said, I keep getting a stack dump error. I should go back to java.

    -Thanks everyone who decideds to help

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    How about actually posting some code? Wait, I have just the thing...

    Quote Originally Posted by kermi3
    Welcome to the boards. If you haven't already done so then please take some time to familiarise yourself with the faq:
    http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

    Make sure you have a look at the the posting guidelines:
    http://cboard.cprogramming.com/annou...ouncementid=51
    Following the rules will ensure you get a prompt answer to your question.

    Remember, too, that the board has a search facility, a link is at the top of your screen:
    http://cboard.cprogramming.com/search.php
    It will often get you a quicker answer to your questions than waiting for a response to one you have posted.

    It appears that you are posting a homework assignment or other project.

    Please don't ask people to do all your work for you, See the announcement on Homework at the top of all forums to see what is acceptable or PM me. Basically people are happy to help, but they're not going to do it all for you.

    Show us what you've got, show your code (using code tags), or where you're confused and someone will be happy to help you I'm sure. If it's something that you absolutely don't understand how it works, like you have no clue how qsort works, then ask a general question about the function and I'm sure someone will explain it. Though they may not give you all of the code for it, but someone will explain the concept.


    On obivous homework questions especially, I like to remind people of the board's ninth guildeline, while this board is very helpful to people, make sure you have your instructor's permission before seeking help on assignments. While people on these boards are more than happy to help, we discourage people from asking for help on graded work without the instructor's permission, and we claim no repsonsibilty for any cheating or honor violations.

    Feel free to PM me with any questions.

    Good Luck,

    Kermi3

    Read and follow the above instructions, and try your post (in the same thread) again.

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

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    4
    Why does everyone say that to me, I'm just asking for advice. Is it a problem that I don't like to post my horrible coding in here? You guys need to come back down to earth and treat other people like people and not just as a nuisance that you can shove away because you know more about a subject, but I'll play along.

    Code:
    	
    //huge long code before here.......
    
            printf("Enter desired fan speed (0-100%):");
    	scanf("%fl", &f1);
    	
                    do {
    		printf("\nYou have not entered a valid speed\n");
    		printf("Enter desired fan speed again:");
    		scanf("%fl", &f1);
    		}while (*a1 < 0 || *a1 > 100);
    	
            printf("Enter second fan's speed:");
    	scanf("%fl", &f2);
    
    //more code after here.........
    This is part if the program that is called by reference then returned to a control panel style menu and the parameters are set after all fan speeds are set. I know this doesn't work. I don't know why. It needs to go for 3 fans inside the comp. while checking the entered value each time. I don't get any problems during compiling, just whenever it goes to check the parameters you get the stackdump thing.

    BTW, I'm 25, I never did homework anyway, and I'm trying to learn this on an accelerated night class after 2 jobs. Get off my back, I'm just trying to learn.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > Is it a problem that I don't like to post my horrible coding in here?
    Well this isn't www.cprogramming-psychics.com, we've no idea which of the many 1000's of possible ways you've messed up without seeing at least some code. And if you don't like to post it all, then at least try and recreate the problem in a small program which you feel happy about posting. This simple act in itself often tells you what you're doing wrong anyway.

    > scanf("%fl", &f1);
    Assuming f1 is a double, the conversion is "%lf", not "%fl"

    > while (*a1 < 0 || *a1 > 100);
    So what's the relationship between f1 and a1?
    Why not have while ( f1 < 0 || f1 > 100 ) ?
    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.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    To further the point, what did you expect? No, seriously. What exactly did you expect?

    There isn't a "stackdump is always caused by you ..." text, or you could just google it your damn self. Your program could potentially have an infinite number of ways you could have written it wrong. I'm supposed to magicly know what one of those it is, just because you say "I"m getting a stack dump."

    Then you have the nerve to ask "Why does everyone say that to me"? Why? Because you're too god damn stupid to read the forum rules in the first place, or apparently the second, or third time, or you'd know that by actually posting some relevant code, it actually helps us help you.

    As stated, this isn't the psychic hotline. If you want to know where your code is broken, you have to show us what it is. You don't just call up the auto shop and say "My car is broken. Why?" And then get ........ed off because he asks you some questions about what it does or doesn't do.

    "Why should I have to bring it into the shop? Can't you tell me over the phone with me not even saying anything other than 'it doesn't work'?"

    Get a clue.

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

  6. #6
    The C-er
    Join Date
    Mar 2004
    Posts
    192
    Yes, when phone my computer vendor and say "my computer's doesn't work" it's hard for them to help.

    If, however I say "I just installed this software for adjusting the CPU fan speed - I turned it down to 0 because it was quieter, then smoke started coming out....

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. Mutiliplcation Program that uses a (do, while, and for loop)?
    By Debbie Bremer in forum C++ Programming
    Replies: 4
    Last Post: 10-11-2008, 06:04 PM
  3. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  4. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 05:00 PM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM