From MSDN, about the %s format specifier and what it reads:
"String, up to first white-space character (space, tab or newline). To read strings not delimited by space characters, use set of square brackets ([ ]), as discussed following Table R.7."
So it must have newlines, or spaces, or the following spec if you know how long the strings should be:
"To store a string without storing a terminating null character (''\0''), use the specification %nc where n is a decimal integer. In this case, the c type character indicates that the argument is a pointer to a character array. The next n characters are read from the input stream into the specified location, and no null character (''\0'') is appended. If n is not specified, its default value is 1."
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
Syntax Question for Tile-Based Engine
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Yes, it does have new lines...The file is like this
111111111111111111111111111111
111111131111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111211111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111211111111111111111
111111111111111111111111111111
111111111111111111115111111111
111111111111111111111111111111
111111111111111111111111111111
111111114111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
161111111111111111111111111111
111111111111111111111111111117
111111111111111111111111111111
111111111111111111111111111111
111111131111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111211111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111211111111111111111
111111111111111111111111111111
111111111111111111115111111111
111111111111111111111111111111
111111111111111111111111111111
111111114111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
161111111111111111111111111111
111111111111111111111111111117
111111111111111111111111111111
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Hmm, are you using visual c++? Can you do a debug run and see what kind of string it retrieves from the file in that offending for loop, the first time?
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Hmmm...I do know how long each line will be, so perhaps I should use nc?
I am using VC++, and I can use the debug...I just have not figured out how yet
I am using VC++, and I can use the debug...I just have not figured out how yet
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
That''s not so hard
Place the cursor on the line that contains the fscanf statement, and press F9. There should be a red dot there now, indicating a breakpoint. This means the program will pause when it reaches that location, and show you the values there.
You want to watch for the value of world[0] in particular. I''m not sure but you may have to open a new watch window ( Under view->debug windows ), and enter world[0] there.
Then you press F10 ( step over ), and it will execute one statement. It might crash, but you should have the value of world[0] in your watch window now;
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
Place the cursor on the line that contains the fscanf statement, and press F9. There should be a red dot there now, indicating a breakpoint. This means the program will pause when it reaches that location, and show you the values there.
You want to watch for the value of world[0] in particular. I''m not sure but you may have to open a new watch window ( Under view->debug windows ), and enter world[0] there.
Then you press F10 ( step over ), and it will execute one statement. It might crash, but you should have the value of world[0] in your watch window now;
#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
I tried using debug. I made it so it just reads in world[0], and when it gets to that line I get an access violation. Then, it goes to where I think the fscanf function may be. It says it's input.c. It stops at a line in there, and then windows just goes to hell. I get 2 illegal operations and I have to restart the computer each time. I watched world[0], and does not change. It's initialized with all 3333's and it stays at that value, but I'm not sure how good of a test it is because of that access violation. Man, this is giving me a headache
Do you realize that you ended your last sentence w/ a semicolon? You're a true C programmer
Edited by - Nazrix on 4/19/00 2:10:53 PM
Edited by - Nazrix on 4/19/00 2:19:37 PM
Do you realize that you ended your last sentence w/ a semicolon? You're a true C programmer
Edited by - Nazrix on 4/19/00 2:10:53 PM
Edited by - Nazrix on 4/19/00 2:19:37 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Is there a possibility (spelled right?) that there's something wrong with your computer (or perhaps it's your Windows version)? Could you upload the exe so we can try it out?
Finally, I'm a MARTYR! Yay! And I owe it all to this thread
/. Muzzafarath
Edited by - Muzzafarath on 4/19/00 2:50:07 PM
Finally, I'm a MARTYR! Yay! And I owe it all to this thread
/. Muzzafarath
Edited by - Muzzafarath on 4/19/00 2:50:07 PM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
hey, I knew I was good for something
I went to a fanatic in no time cause of this thread
Sure, I could upload it...
Just a sec...
I went to a fanatic in no time cause of this thread
Sure, I could upload it...
Just a sec...
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
I uploaded it to angelfire's ftp. I can't make it get there to download it through the browser, but if you connect to
ftp.angelfire.com and use /in/bakergame as the user name and chris2 as the password you can download it with an ftp program. Sorry I can't seem to make it work any other way. I know I've done it before, but I think I'm becoming mentally exhausted here
I think perhaps the problem is that you need a password to get in...
Edited by - Nazrix on 4/19/00 3:38:32 PM
ftp.angelfire.com and use /in/bakergame as the user name and chris2 as the password you can download it with an ftp program. Sorry I can't seem to make it work any other way. I know I've done it before, but I think I'm becoming mentally exhausted here
I think perhaps the problem is that you need a password to get in...
Edited by - Nazrix on 4/19/00 3:38:32 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement