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.
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.
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.
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
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.
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).
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.
i know i'm trying to do what "http://911programming.wordpress.com/2010/05/15/sample-c-io-student-recods/" is doing.
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.
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???
So there is such a thing as the manual. Why not read it?
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.
Well, no; that's kinda what "reading" means. I mean, let's look at the bit in the manual about *:
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.Originally Posted by linux scanf manual
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.
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);
How about
assuming I have remembered which fields were where in the file.Code:sscanf(buffer, "%[^,], %[^,], %*[^,], %*[^,], %*[^,], %[^,]", get_info.user_ID, get_info.pass_word, get_info.user_flag)
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.