![]() |
|
#1
|
|||
|
|||
need help - questions about stringsin C:
i cant use string.h 1) i need to write function that gets 2 strings and searcg for the longest mini string that appear in the 2 strings. the function will write the mini string to a new string and return ger length 2) i need to write function that get s 2 strings. if thay are equal the function will return 0. otherwise return -1, but there is no different between capital letters and small letters. exaple: For BOB and Bob return 0 3) i need to write a function that gets a string and a word. the function return how many times the word appear in the string. thw words in the strings separate by any sign that is not a letter. thare is no differnet between Caputal and small letters. example : string : One,two-onton;one,three.ONE'TWO.Two-four\one word: One the function return 4 10x |
|||
|
#2
|
|||
|
|||
|
Quote:
Using string.h is easy. Just put this near the beginning of your program file: CPP / C++ / C Code:
Now, if your question is about how to use some of the functions declared in string.h to perform your assigned tasks, look for a reference in your text book, class notes, or whatever. You can use a search engine to find information. (Just to get you started, one link that I found is http://www.cplusplus.com/ref/cstring/). This describes the functionality of functions such as strcmp(), strcpy(), strcat(), strstr(), etc. If you try to do something and it doesn't work the way you think it should, post the code that shows what you are attempting. Tell us what you got, what you expected to get, specifically what you don't understand, etc. Tell us what compiler and operating system you are using (sometimes it matters). Regards, Dave |
|
#3
|
|||
|
|||
you didnt understand meyou didnt understand me
i cant use string.h iknow how to use it but the instructions say that i can use inly stdio.h |
|
#4
|
|||
|
|||
|
Quote:
I'm sorry that I didn't understand what you were asking for. [edit] Come to think about it, you didn't actually ask a question. I was just guessing. And I'm still just guessing that you want some help in fulfilling your assignment. [/edit] If you know how to use the standard library string manipulation functions, write a program using functions like strcat(), strcpy(), strcmp(), etc. Test the program(s) with whatever inputs you want to apply. Then, one at a time, implement your own version of the functions and plug them into your test program. Show us what you have so far, and ask specific questions. Regards, Dave Last edited by davekw7x : 21-Jan-2005 at 13:05.
|
|
#5
|
||||
|
||||
|
Are you saying that you are not allowed to use string.h in your program, instead your only allowed to use stdio.h? If that is the case your program is going to be a bit larger.
1)You could always use arrays. It would be ackward and take a bit of programming but you coudl always have a bunch of character arrays and use those instead of strings. You'd need two temp arrays. fill the first one with the first mini string, second one with the second mini string. Have two counters that tract the amount of characters that go into each string. Which everyone has the highest amount you keep. The other one you simply overwrite and reset the counter. Just keep this up untill you hit the end of your array. The string in question will be in the larger of your temp arrays. 2)No ideal how to do this with out string compare unless you know there size already. Then its simply comparing array1[x] to array2[x], where x is whatever index number. 3)You'd have to do something simular to what i said in responce to number 1. __________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
|
#6
|
||||
|
||||
|
Quote:
__________________
The 3 Laws of the Procrastination Society: 1) Never do today that which can be put off until tomorrow 2) Tomorrow never comes |
|
#7
|
||||
|
||||
|
I find it easier to think of arrays and strings as differnt, especially since strings.h is not to be used. By saying they are an array of characters and not strings, you don't need to remember that pesky null terminator too.
__________________
"To argue with a person who has renounced the use of reason is like administering medicine to the dead." -Thomas Paine www.sullivan-county.com/deism.htm |
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| array of pointers to strings | mirizar | C++ Forum | 5 | 21-Jan-2005 10:24 |
| C++ style strings and STL | dexter | C++ Forum | 14 | 04-Jan-2005 07:46 |
| Help! Some basal questions about MFC | xutingnjupt | MS Visual C++ / MFC Forum | 1 | 05-Dec-2004 03:38 |
| I am reviewing Arrays and need help converting some strings to arrays | jenmaz | C Programming Language | 22 | 22-Nov-2004 23:26 |
| comparing strings | yarons | C Programming Language | 6 | 19-Oct-2004 21:03 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The