|
Entertainment & Technology Discussion of music, games, movies, and computer technology. |
|
Thread Tools | Display Modes |
10-22-2011, 09:16 PM | #1 | |
oaty the dimejizz
|
C question
Much like roddney, I also need help with my programming. I'm working on this C parser (correct word?) that will work on a copy and pasted nation screen. The problem I'm running into here is the fact that printing a string from an array is not working at all for some reason, but the array definitely contains the characters, as proven by the printf() in the loop that reads the wanted data. All that is printed to file is two spaces, at least I think they are spaces. There is probably some ridiculously easier way to do this, and you are free to point that out as well. Without further adieu, here is the code:
PHP Code:
I guess I could use a loop to print every character individually, but that just seems like more work than necessary.
__________________
Spiced Rum War Vet
|
|
10-22-2011, 09:31 PM | #2 | ||
Optio
|
Re: C question
Quote:
This was back when punch cards were made out of stone tablets, so... I'm sure someone else knows.
|
||
10-22-2011, 09:38 PM | #3 | ||
oaty the dimejizz
|
Re: C question
Quote:
Anyway, in C, you can print an entire string with the %s as long as the array has the string characters starting on index 0.... oh wow I just figured out what is wrong with this as I was typing. I have a space before the : and S and the end of a string is a whitespace character iirc. Lets see if this works. EDIT: Oh boy, progress, I got it to print an 'e' which is the last character (it should be SpecialMike). I added an if(character != ' ') before assigning the character to the array. Also, as I was saying, in C you don't HAVE to loop and print each character individually, but you can. I chose the character-by-character method of assignment because of the broadness of different things in the copy and pasted file.
__________________
Spiced Rum War Vet
Last edited by SpecialMike; 10-22-2011 at 09:46 PM. |
||
10-22-2011, 09:43 PM | #4 | |
Optio
|
Re: C question
Giving vague advice based on outdated methods with a conclusion to seek more advice until the other person finally just figures it out on their own. Hmmm...
I should be a professional consultant. That's pretty much how they work. Let is know if your solution fixes it.
|
|
10-22-2011, 09:55 PM | #5 | |
oaty the dimejizz
|
Re: C question
It sorta worked, but I think there is another weird character in there like a tab or something that isn't just a space that I really don't feel like figuring out right now because I'm tired and want some sleep. That, and I'm lazy. I'll figure it out in the morning, I'm tired of smashing my head against the keyboard for hours on end.
Also, I shall keep that in mind, when someone asks for help just give a vague answer and tell them to wait for someone who knows what they are working on to help. You're on a streak with that one. Mornings are great for thinking. I'm an idiot and was setting j to 0 every iteration, so the first index of the array was constantly being overwritten. Now it works, and I feel accomplished, but there is probably an easier way that I don't feel like figuring out right now.
__________________
Spiced Rum War Vet
Last edited by SpecialMike; 10-23-2011 at 06:57 AM. |
|
12-21-2011, 09:24 PM | #6 | |
Nation: Presldent Marin Current Wars | Foreign Aid Discord name: PresidentMarin Alliance: The Last Republic Join Date: Dec 2011
Posts: 192
|
Re: C question
spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spams spam spam spam
|
|
12-21-2011, 09:25 PM | #7 | |
Re: C question
__________________
|
||
|
Tags |
question |
|
|
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc. |