Thread: gets and puts does'nt work!!

  1. #16
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by Adak View Post
    I'm sure he's not a liar, and that kind of language is insulting, anyway. He just doesn't know how to make the code work.
    Him asking for help without describing the problem is insulting, since it's a waste of our time.

  2. #17
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by MacGyver View Post
    Him asking for help without describing the problem is insulting, since it's a waste of our time.
    He's new, and a beginner. I agree he could be more helpful, but name-calling is bad forum etiquette, and not helpful, either.

  3. #18
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    He's also a student trying to get us to help him with his homework. The fact he's not putting forth the effort to even make us understand what the problem is suggests he may not even be putting forth the effort to do the work himself. In which case, name-calling might slap him awake long enough to realize he's a newbie and motivate him to strive to get to the level of the supposed experts.

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    He's new, and a beginner. I agree he could be more helpful, but name-calling is bad forum etiquette, and not helpful, either.
    If you think my statement is offensive even though I qualified it with "at least until you provide proof that it does not work for you" and explained what is required (for a second time considering Salem had already explained it), then use the report post button to report my post.

    Until then, let's wait for a reply by behzad_shabani that hopefully has further explanation and a sufficient code example.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #20
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    In a small and simple code it worked! but when I put it in my original code it doesn't work!
    I don't know where is my fault!

  6. #21
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Post
    the
    code
    already
    .

  7. #22
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    In a small and simple code it worked! but when I put it in my original code it doesn't work!
    I don't know where is my fault!
    One approach if you really do not know where is the problem is to rewrite your code based on the small and simple code that you know works. Code incrementally, so when you add a few lines and suddenly the code stops working, you know the problem is likely in those lines that you added (or perhaps it is elsewhere, but came to light when those lines were added).

    Of course, if all else fails, then you simply have to provide the original code, but the problem with that is that if it is too big a sample, nobody will read it and thus nobody will help you (unless they happen to be very bored).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #23
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    If I wast off your time you can report this thread to moderator to close! or report me to ban!
    I just ASK for help, I'm not forcing you to help!

    Don't forget someday you was just like me!

  9. #24
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    If you want help, post your code so we can figure out what you're doing wrong. If you can't understand this, then you're not going to get any help.

  10. #25
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    I think I could solve the problem!
    thank you laserlight, Salem and other who helps me!

  11. #26
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103

    Thumbs down C sucks! in reading stream

    gets, fgets, scanf, sscanf, and other stream reading function SUCKS

    I wrote a function by MYSELF:
    Code:
    /*****getstr(): getting an stream*****/
    // WRITTEN BY: Behzad Shabani
    // CALLING FUNCTION: getstr(stream);
    
    void getstr(char* stream){
    
    	/* function variables */
    	int i, flag = 0;
    	char ch;
    
    	/* function process*/
    	for (i = 0; flag == 0; i++){
    		ch = getche();
    		if (ch == '\r'){
    			if (i != 0){
    			stream[i] = '\0';
    			flag = 1;
    			continue;
    			}
    			else {
    				printf("\a");
    				i--;
    				continue;
    			}
    		}
    		else if (ch == '\b'){
    			printf("\b");
    			i--;
    			continue;
    		}
    		stream[i] = ch;
    	}
    
    }

  12. #27
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    What sucks is your use of non-portable functions from conio.h (which is obsolete).
    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.

  13. #28
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Awesome. A garbage version of gets(). Oh, I can't wait to use this in my next virus.

  14. #29
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    Quote Originally Posted by MacGyver View Post
    Awesome. A garbage version of gets(). Oh, I can't wait to use this in my next virus.
    hehe

  15. #30
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by behzad_shabani
    hehe
    Eh, do you realise that your functions sucks even more than gets(), which sucks really badly? The problem with gets() is that the length of the string is not specified, so it is vulnerable to a buffer overrun.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed