FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


C++ Assignment! its about string.h





bcnhs81
Hello guys I have a Homework in my programming..and i really need your help on this one.. so here it is..

1. Palindrome

Sample Output#1
--------------------

Enter A String: Hello There

Hello There!erehT olleH

Sample Output #2
-----------------------

Enter A String: Let's go.

Let's go.og s'teL

2. Search String

Sample Output
-----------------

Enter a String:The quick brown fox jumps

Enter (sub) string to search: fox
fox-found!!

Sample Output 2
---------------------

Enter a String: The quick brown fox jumps
Enter (sub) string to search: dog
dog-not found

_-----------------------------------
Thanks a lo to those who will help me.. I really cant understand the string thingy in C++...thanks...
clip
It's an assignment. Are you sure that we're allowed to help you?

I know how to do that, but you have to learn too y'know.

http://www-ccs.ucsd.edu/c/string.html <--- it's a list of all <string.h> functions. It would help you a lot.

Very Happy
bcnhs81
im trying 2 understand it but to no avail.. please guys. its been 3 days already.. our teacher is very hard 2 comprehend.. i hope you can help me just this once...
Shin
At least you have to tell us what have you done so far, and which particular area that you have got stucked. You shouldn't expect us to just post the code to you. I hope you don't get upset, but if we do post the code to you then we are NOT helping you. you know?

OK, I will give you some hints so you can give it a try first, then post the question if you have one later.

The assignment is about String manipulation.
String is store in an Array (of char).
Array has indexes that begin with 0, then 1, 2, 3 and so on. Hnece you can access each character in the string ot array by using '[]' operator.
The size of the array is equal to the length of the string plus one for Null Terminator.
Null terminator is represented by '\0'.

Hope this gives you some idea to begin with.
virtualpointer
1. Palindrome

Sample Output#1
--------------------

Enter A String: Hello There

Hello There!erehT olleH

Sample Output #2
-----------------------

Enter A String: Let's go.

Let's go.og s'teL

============================================================

The following code is nearly there

[code]#include <string>
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
string s, s1;

if(argc>1){
s.append(argv[1]);
s1.append(argv[1]);
}
for( int i=0 ; i<s.length() ; i++ ){
s1[i] = s[s.length()-i-1];
cout<<i<<" "<<s1<<" <-- "<<s[s.length()-i-1]<<endl;
}
s.append(s1);
cout << s << endl;
}[/code]


Modify it to fit your requirement.[/code]
Related topics
C++ Strings
C++ code help
C++ assignment help
Explaination about this C++ code needed
[help]Ejercicio en lenguaje C
C/C++
C++ for beginners
[C] Splitting names program
which Programing launguage to learn
Slight problem with C code
c++ ile programlamaya giri₫
c++ ile programlamaya devam....
MU &#272;&#7897;c Tôn SS5 - H&#7913;a h&#786
euroeng.c [Pt. 1]
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.