Thread: help fast T.T

  1. #31
    Registered User
    Join Date
    Jul 2008
    Posts
    133
    Quote Originally Posted by iMalc View Post
    ...
    But, when people deviate from forum rules, and are learning about english, knowledge, behaviour and hormone control, isn't that nice opporunity for others to practice something else (anything you like) ?

  2. #32
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    >> now my problem is i have debug error if an user key in the username or password more than 30chars.

    Well here is a list of things you could be going wrong:
    • the arrays your using might be too small for thirty or more characters
    • if that's the case, then fgets will likely read debris you are not interested in as the password
    • earlier scanf calls could cause fgets to read debris


    This would be a lot easier an experience for you if you would just stop saying "Help, help! My homework is so important!" and inform us of your progress in a smart way. Code, for example, would be nice to see.

    In general your whole approach to string input doesn't seem to be working. If you can't find the problem and fix it from that list, then try this.

    • read into a decent sized buffer, as in a few kilobytes large
    • make sure the string is the correct length
    • morph the string to a uniform case
    • copy from the huge temporary buffer into your smaller username and pass strings


    That seems like a better approach at the moment, but do whatever you want -_-
    Last edited by whiteflags; 08-17-2008 at 06:54 PM.

  3. #33
    Registered User
    Join Date
    Aug 2008
    Posts
    16
    yea, i tried myself and complete the assignment although it tooks me alot of time and many times of failure, but feel very happy now.
    i still have some question, don't worry, i m not asking you to help me complete my homework, i just want my assignment to be more perfect

    my data input that prompt the user to key in is 'P123456', i use gets ( data );, i want to ask how to detect the user was type 'D123456' but not 'P123456'? how to compare and i will use printf("You key in the wrong format, please key in again");
    Last edited by yrhc@eht; 08-19-2008 at 06:39 PM.

  4. #34
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by yrhc@eht View Post
    yea, i tried myself and complete the assignment although it tooks me alot of time and many times of failure, but feel very happy now.
    i still have some question, don't worry, i m not asking you to help me complete my homework, i just want my assignment to be more perfect

    my data input that prompt the user to key in is 'P123456', i use gets ( data );, i want to ask how to detect the user was type 'D123456' but not 'P123456'? how to compare and i will use printf("You key in the wrong format, please key in again");
    If you know how to check for P123456, you know how to check for D123456.

  5. #35
    Registered User
    Join Date
    Jul 2008
    Posts
    133
    If you have string like "char data[100];", or "char *data = malloc(100);", you can check individual characters with "index" operator. In both cases, data[0] is 1st letter, data[1] second, and so on...

  6. #36
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > i use gets ( data )
    Well you should stop, and read the FAQ

    Today it's "D123456"
    Tomorrow is "D123456aaaaaaaaaaaaaaaaaaaa\12\34\56\78" and your box is now on a botnet owned by someone else.
    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.

  7. #37
    Registered User
    Join Date
    Aug 2008
    Posts
    16
    yea, i want to compare if an user input different format from D123456, i write char call_number [ 7 ];, gets ( call_number );, then i try to run the program, as an user, i key in D123456, i have debug error, what should i write the gets (call_number) so i will not have debug error even though the user has exceed the limit chararters ( D123456 ) ?

  8. #38
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    The FAQ is over here. You should take a look - it answers your questions, and possibly some others you might have at a later date.

    Please look at the "why gets() is bad" article also.

    It's not that we aren't here to help, but your problem is very common, so it's better to just look up the answers.

    Then later, if you still have problems, then we'd be happy to fix your code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 02-27-2009, 04:43 PM
  2. Saving a part of screen into a file fast!
    By Zap in forum C++ Programming
    Replies: 4
    Last Post: 06-28-2003, 10:56 AM
  3. Super fast bilinear interpolation
    By VirtualAce in forum Game Programming
    Replies: 2
    Last Post: 06-18-2002, 09:35 PM
  4. moving a bitmap, fast and smooth
    By werdy666 in forum Game Programming
    Replies: 1
    Last Post: 05-31-2002, 06:49 PM