Questions about the two

C++ Library Functions and manipluation of charater strings.

Posted 07 December 2008 - 08:58 PM

I am creating a program that uses 6-library functions and demonstrates the manipulation of character strings. So my question is...
What are some of the most basic functions that will make this as easy as possible.
Also what is the best way to incorporate these 6 functions into a character string.

This is for school and I believe we just need to show our basic understanding of functions and character strings. I don't want to pick 6 random functions since I may be doing more work then I need. I am not quite sure what it means to manipulate a character string. Something like inputting a couple numbers incrementing or decrementing/ formatting them ?

Re: C++ Library Functions and manipluation of charater strings.

Posted 07 December 2008 - 09:31 PM

I assume its STL and yes it is C-strings. My teacher does not speak the best English so hes kinda hard to understand. I had him explain it a little more and he mentioned that it could be done with an array.

This post has been edited by ShakeZula.219: 07 December 2008 - 09:33 PM

The program takes a number and doubles it.
I think this counts as two functions. I was wondering how I would save the number in an array so I could add some other functions. Like A function for increment and decrement.

Re: C++ Library Functions and manipluation of charater strings.

I am kind of confused if I am doing this correct. This is the problem we have to complete.

"Design an application that demonstrate use of six-Library function and demonstrate the manipulation of character strings."

Can anyone clear up what a Library Function is? And how you can use that to manipulate character Strings. I went to the link your provided KYA but we haven't studied those functions in school. So I wonder if he would really have us design a program with functions we haven't used?

Re: C++ Library Functions and manipluation of charater strings.

Posted 08 December 2008 - 01:21 PM

Could've swore I wrote a very long and elaborated post here last night that I (thankfully) copied and pasted to a textfile... I'll assume I did and somebody (without justification OR notification) removed it.

At anyrate, you created a bunch of functions rather than using the predefined functions in the library (like strcpy, strcmp, strcat, etc etc).

Re: C++ Library Functions and manipluation of charater strings.

Re: C++ Library Functions and manipluation of charater strings.

Posted 08 December 2008 - 10:39 PM

Hey guys, This is what I have so far.
Its a program that asks the user for their first name.
it uses strcmp to find if the string is equal to my name Dan, if it is then it outputs "That's my name theif". If not than it outputs "That names stupid".
Then the program tells the user the number of characters in there first name. Then it asks for the last name and uses a function to combine them. I used another function to copy one string to another and then output the whole name. I have 4 library Functions in use now, I need to add to more.
Any simple functions you guys think I could add too this easily??

#include <iostream> //For cout
#include <cstring> //For the string functions
using namespace std;
void main(void)
{
char name[50];
char lastname[50];
char fullname[100]; // Big enough to hold both name and lastname
char allname[100]; //so I can use strcpy
cout<<"Please enter your first name: ";
cin.getline ( name, 50 );
if ( strcmp ( name, "Dan" ) == 0 ) // Equal strings
cout<<"That's my name theif!.\n";
else // Not equal
cout<<"That names stupid.\n";
// Find the length of your name
cout<<"Your name is "<< strlen ( name ) <<" letters long\n";
cout<<"Enter your last name: ";
cin.getline ( lastname, 50 );
fullname[0] = '\0'; // strcat searches for '\0' to cat after
strcat ( fullname, name ); // Copy name string into full name string
strcat ( fullname, " " ); // We want to separate the names by a space
strcat ( fullname, lastname ); // Copy lastname onto the end of fullname
strcpy (allname, fullname); // Copy The whole string "Fullname" into "Allname"
cout<<"Your full name is "<< allname <<"\n";
cin.get();
}
//"STRCPY" Copies one string to another.
//"STRLEN" This function counts
// and returns the number of characters in a string.
//"STRCAT" add the characters of one string to the end of other string
//"STRCMP" which returns a zero
//if 2 strings are equal, or a non zero number if the
//strings are not the same.