![]() |
|
#1
|
|||
|
|||
How to read the data as a whole string?Quote:
And also if I do this,how do I switch the firstname and lastname,and how to compute the ave score?(How do I take the 3 scores out of the whole string?) |
|
#2
|
|||
|
|||
Re: How to read the data as a whole string?Quote:
You can read up reference API for CPP / C++ / C Code:
CPP / C++ / C Code:
Hope this helps! |
|
#3
|
|||
|
|||
Re: How to read the data as a whole string?The reason for homework is to get you to think not to try to get someone to do it for you. What are you going to do when you get a job?
|
|
#4
|
|||
|
|||
Re: How to read the data as a whole string?Quote:
I am trying to do it,but I really don't know how to do.I think I put my question here is just the same as I ask it to my professor,the point is you can get the right answer no matter whom you asked.I think I am doing right and I am working hard on it. Let me ask you:when you are in trouble,do you always just try it by yourself even you can't finish it without anybody's help and never ask for help?I am not cheating,and I am not let you to do it for me.I just want to get some hint! Even I am getting my job,if I am in trouble,I will ask for help.I don't think that is so bad,by this way,you can get more and more experience and at last you can do your programming by yourself.Can you say |
|
#5
|
|||
|
|||
Re: How to read the data as a whole string?To save ou some time in searching. I have provided links to the reference API.
fscanf http://www.cplusplus.com/reference/c...io/fscanf.html fgets http://www.cplusplus.com/reference/c...dio/fgets.html fread http://www.cplusplus.com/reference/c...dio/fread.html Now its up to you to determine which is better for u. I would reckon you try both fscanf and fgets. One difference is the delimiter and how they get the values from the buffer. If your data is multi-format( eg. %s, %d, %f), fscanf would be better as lesser code is needed to convert from char to integer, double etc. Another point to take note is that if the number of entries. This will determine whether to use a for loop ofr while loop. I believe all this will be delivered in your assignment specifications. Hope this helps. |
|
#6
|
|||
|
|||
Re: How to read the data as a whole string?Thank you ,man!My other question is how to do "sorted by last name
with each of the last names fully capitalized (that is, if you read in Wilkinson you print WILKINSON) ",change the letters to fully capitalized? Why it is wrong? CPP / C++ / C Code:
Last edited by LuciWiz : 31-May-2007 at 12:01.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#7
|
|||
|
|||
Re: How to read the data as a whole string?Well at least tell us what is wrong so we can address it. From the look of the source code,
CPP / C++ / C Code:
c_str() in <string> to get the C string equivalent and then use toupper to convert each char to uppercase. This is the trival method. About sorting, you can search in STL <algorithms> tp find a suitable sorting algorithm. Hope this helps. |
Recent GIDBlog
Meeting the populace by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Message Class | TransformedBG | C++ Forum | 5 | 29-Nov-2006 21:28 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| Help wit my source code compiler errors | Krandygrl00 | C++ Forum | 1 | 06-Jun-2005 08:14 |
| Using getline to read in data | krisbot | C Programming Language | 4 | 24-Oct-2004 15:57 |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 15:13 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The