![]() |
|
#1
|
|||
|
|||
Making a Variable equal a letter in CHi
I'm trying to make a variable in my program equal a letter, i don't know how to do it, i'm sturggling to find out how you can do it, hence the posting here. Here is the code, bare in mind its still a bit scrappy: CPP / C++ / C Code:
Can anyone help??? Last edited by dsmith : 26-Aug-2004 at 06:55.
Reason: Please use [c] & [/c] for syntax highlighting
|
|
#2
|
||||
|
||||
|
Quote:
Hi Phoenix. Yep, many people can help. The immediate answer to your question is: CPP / C++ / C Code:
Now that that's out of the way, you have a few problems I hope you don't mind me pointing out. 1) Use code tags, not font tags around your code. 2) Your definitions: CPP / C++ / C Code:
CPP / C++ / C Code:
3) You immediately try to open a file using argv[1], then you check if argv[1] is a valid value. This can cause lots of trouble, not to mention it's bad form. And you are also checking to see if the argv[1] is NULL. Try this instead: CPP / C++ / C Code:
4) All your fgetc() stuff is just reading from the file throwing away possibly good data. Simply read the data now, remembering we changed the values above to just chars: CPP / C++ / C Code:
CPP / C++ / C Code:
the %9s tells sscanf() the function to read 9 characters (all your name string can hold) and fill the last character with the needed null __________________
Age is unimportant -- except in cheese |
Recent GIDBlog
Flickr uploads of IA pictures by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Get value for variable name defined as string | mirizar | C Programming Language | 3 | 21-Jun-2004 17:36 |
| Keeping track of a private variable outside the class | viperv80 | C++ Forum | 1 | 03-Dec-2003 17:25 |
| Help making a survey in C++ | elavalos | C++ Forum | 2 | 23-Sep-2003 16:40 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The