Thread: "simple" login authorization code

  1. #31
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    get_info.user_ID
    get_info.pass_word
    get_info.first_name
    get_info.last_name
    get_info.user_flag

    If you try to count those, and only manage to count to 1, I think we've got other problems here.

  2. #32
    Registered User
    Join Date
    Nov 2013
    Posts
    34
    Could you expand on your answer?

    Really I could type in random stuff into my code to what I think it is, but that's not going to help me.

    Had I been given information like on page 2 from the start, a week ago, I wouldn't be in this mess.

    So really someone owes me here for lost time.

    I'm under a deadline here.
    Last edited by jkgoose937; 12-08-2013 at 04:49 PM.

  3. #33
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    How else would you explain the line
    Code:
    sscanf(buffer,"%[^,], %[^,], %[^,], %[^,], %[^,]", get_info.user_ID, get_info.pass_word, get_info.first_name, get_info.last_name, get_info.user_flag) == 1
    ?

  4. #34
    Registered User
    Join Date
    Nov 2013
    Posts
    34
    sscanf(buffer,"%[^,], %[^,], %[^,], %[^,], %[^,]", get_info.user_ID, get_info.pass_word, get_info.first_name, get_info.last_name, get_info.user_flag) == 1

    sscanf: is reading within the file by line

    buffer: is the entire file

    "%[^,], %[^,], %[^,], %[^,], %[^,]": is reading comma separated data and skipping commas

    get_info.user_ID, get_info.pass_word, get_info.first_name, get_info.last_name, get_info.user_flag: is the memory place holders for the infomation

    == 1: 1 for true, 0 for false.

    this is how i see it.

  5. #35
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Then you should get your glasses on and read the manual for sscanf, specifically about the value it returns (which isn't true/false, but the number of items read).

  6. #36
    Registered User
    Join Date
    Nov 2013
    Posts
    34
    so because i only really need the first 3 variables it should be:

    sscanf(buffer,"%[^,], %[^,], %[^,]", get_info.user_ID, get_info.pass_word, get_info.user_flag) == 3);

    so if the above is true, how would i search or read the next line in my database file if the information being compared isn't true?
    Last edited by jkgoose937; 12-08-2013 at 05:22 PM.

  7. #37
    Registered User
    Join Date
    Nov 2013
    Posts
    34
    i know i'm trying to do what "http://911programming.wordpress.com/2010/05/15/sample-c-io-student-recods/" is doing.

  8. #38
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You can't use "%[^,], %[^,], %[^,]" as the format, because that's not the format that the data is in. Have you read the manual yet? You may want to explore what * can do for you.

  9. #39
    Registered User
    Join Date
    Nov 2013
    Posts
    34
    i do have C the complete reference 4th edition, but it's vague or moot on what i'm trying to do here.

    there is a bit more online:
    Sample C I/O: Student Records | 911 programming

    but again not really what i'm trying to do.

    it's seems as if nobody is doing it this way.

    is there another direction i should be taking???

  10. #40
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    So there is such a thing as the manual. Why not read it?

  11. #41
    Registered User
    Join Date
    Nov 2013
    Posts
    34
    yeah, that doesn't help. there again no information on what i'm trying to do. no examples, nothing!

    http://www.daniweb.com/software-deve...a-login-system

    this is a bit closer to what i'm trying to do, but again my dilemma how to read from a database?

    it's one thing to read text it's another to understand what the text means.
    you have a background in all this, but this is my first time and this is what i was given to create a login code to read from a database.

    it's got to be possible but there isn't enough information out there that has what i'm looking for.
    Last edited by jkgoose937; 12-08-2013 at 07:55 PM.

  12. #42
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by jkgoose937 View Post
    it's one thing to read text it's another to understand what the text means.
    Well, no; that's kinda what "reading" means. I mean, let's look at the bit in the manual about *:
    Quote Originally Posted by linux scanf manual
    An optional '*' assignment-suppression character: scanf() reads input as directed by the conversion specification, but discards the input. No corresponding pointer argument is required, and this specification is not included in the count of successful assignments returned by scanf().
    That seems fairly straightforward to me: if you put a * in the conversion, scanf reads the input as the format would normally indicate, but doesn't actually try to store that information anywhere. You also don't have to include an argument for it in your inputs.

    If you have six items on a line (making up a record), you've got to indicate that in your format string -- the format string must match the input format, that's why it's there. If you don't care about three of those fields, then you can use a * to indicate that those values shouldn't be stored. But you can't leave them out of the format.

  13. #43
    Registered User
    Join Date
    Nov 2013
    Posts
    34
    so if i'm understanding:

    a: sscanf(buffer,"%[^,], %[^,], %[^,]", get_info.user_ID, get_info.pass_word, get_info.user_flag, *, *, *,) == 3);
    or
    b: sscanf(buffer,"%[^,], %[^,], %[^,], *, *, *", get_info.user_ID, get_info.pass_word, get_info.user_flag, *, *, *,) == 3);

  14. #44
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    How about
    Code:
    sscanf(buffer, "%[^,], %[^,], %*[^,], %*[^,], %*[^,], %[^,]", get_info.user_ID, get_info.pass_word, get_info.user_flag)
    assuming I have remembered which fields were where in the file.

  15. #45
    Registered User
    Join Date
    Nov 2013
    Posts
    34
    Why does it take 12 posts to finally get somewhere?

    I have been more than upfront about my lack of understanding here.

    I have lost all respect and faith in this forum.

    People here may be skilled in programming but lack in teaching skills.

    I really had hopes to one day to contribute to the Linux community and became a programmer.

    It's not about giving up per se, but rather knowing that for first time students your better of beating your head against the wall.

    I'm not going to apologize for my frustrations here, that would go against everything I believe,
    but I hope it's a warning to others that wish to get help, know programming first.

    I'm done.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 08-19-2012, 06:15 AM
  2. An interesting code about "struct" in "union"
    By meili100 in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2008, 04:37 AM
  3. login "scripts"
    By Thantos in forum Linux Programming
    Replies: 4
    Last Post: 12-02-2003, 08:14 PM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM