C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-11-2002, 01:45 PM   #1
Registered User
 
Join Date: Apr 2002
Posts: 249
Wink Strings are V important...

Dears,
As a Begginer student for C++, I know something about it but Please do us a favor.

Students will be thankfull for you ... If you support us , with alll the C++ string Functions ... So Please do...
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-11-2002, 01:50 PM   #2
Registered User
 
Join Date: Apr 2002
Posts: 249
Exclamation strerror()

I got this one as the strang Function....

Prototype: char *strerror(int errnum);
Header File: string.h
Explanation: Strerror returns a pointer to a string that contains the identification for an error-number. This is usually used with a function that returns an error number based on the result of an operation. It is a very bad idea to start modifying the string it returns.
//Example prints out error number 2 #include <iostream.h> #include <string.h> int main() { cout<<strerror(2); return 0; }

One more Please............?
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-11-2002, 01:52 PM   #3
Registered User
 
Join Date: Apr 2002
Posts: 249
Arrow strcmp()

Compar function:

strcomp()

Prototype: int strcmp (const char *string1, const char *string2);

Header File: string.h
Explanation: Tests the strings for equality. Returns a negative number if string1 is less than string2, returns zero if the two strings are equal, and returns a positive number is string1 is greater than string2
//Example reads in two strings (w/out spaces) and compares them for equality
#include <string.h>
#include <iostream.h>
int main()
{
char *str1=new char[20];
char *str2=new char[20];
cin>>str1;
cin>>str2;
if(!strcmp(str1, str2)
cout<<"Strings are equal!";
return 0;
}

/* one more Please......
*/
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-11-2002, 03:31 PM   #4
Registered User
 
Join Date: Apr 2002
Posts: 249
Unhappy Do you have any new Function...

Please add some string magic functions
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-11-2002, 03:35 PM   #5
Registered User
 
Join Date: Apr 2002
Posts: 249
Strcat()

strcat()
Prototype: char *strcat(char *Destination, char *Source);
Header File: string.h
Explanation: This function will concatenate (add to the end) the string pointed to by source on to the string pointed to by Destination. Returns a pointer to the Destination string.
Example:
//Example concatenates two strings to output
//By asking the user for input
#include <string.h>
#include <iostream.h>
int main()
{
char *s1 = new char[30];
char *s2 = new char[30];
cout<<"Enter string one(without spaces): ";
cin>>s1;
cout<<"Enter string two(without spaces): ";
cin>>s2;
cout<<strcat(s1, s2);
return 0;
}


/*********** THIS IS NICE ONE **************/
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-11-2002, 03:36 PM   #6
Registered User
 
Join Date: Apr 2002
Posts: 249
memcmp()

memcmp()
Prototype: int memcmp(const void *buffer1, const void *buffer2, size_t count);
Header File: string.h
Explanation: Alphabetically compares two arrays passed in to it. The fact that it is a void * simply means that it can have non-character arrays passed in to it. It is also necessary to pass how far to compare (ie, the size of the arrays) The return value is:
Less than zero buffer1 is less than buffer2
Zero buffer1 is equal to buffer2
Greater than zero buffer1 is greater than buffer2

Example:
//Program compares two character arrays
//Program compares only to eight letters
#include <stdlib.h>
#include <iostream.h>

int main()
{
int comp_val=memcmp("Andersronc", "Zandimva", 8);
if(comp_val==0)
cout<<"strings are equal";
if(comp_val<0)
cout<<"String one is alphabetically equal";
else
cout<<"String one is alphabetically greater";
return 0;
}
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-11-2002, 03:37 PM   #7
Unregistered
Guest
 
Posts: n/a
Anyone know what this thread is all about?
  Reply With Quote
Old 04-11-2002, 03:37 PM   #8
Registered User
 
Join Date: Apr 2002
Posts: 249
strcpy()

strcpy()
Prototype: char *strcpy(char *dest, char *tocopy);
Header File: string.h
Explanation: Strcpy will copy the string pointed to by tocopy into the string pointed to by dest.
//Example copies a string and outputs the copied string
#include <iostream.h>
#include <string.h>
int main()
{
char *a_string=new char[20];
strcpy(a_string, "Hello, world...");
cout<<a_string;
return 0;
}
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-11-2002, 03:48 PM   #9
Registered User
 
Join Date: Apr 2002
Posts: 249
Some more ....

Here is a full pacage.......

<string.h>
#define NULL <either 0, 0L, or (void *)0> [0 in C++]
void *memchr(const void *s, int c, size_t n); [not in C++]
const void *memchr(const void *s, int c, size_t n); [C++ only]
void *memchr(void *s, int c, size_t n); [C++ only]
int memcmp(const void *s1, const void *s2, size_t n);
void *memcpy(void *s1, const void *s2, size_t n);
void *memmove(void *s1, const void *s2, size_t n);
void *memset(void *s, int c, size_t n);
typedef ui-type size_t;
char *strcat(char *s1, const char *s2);
char *strchr(const char *s, int c); [not in C++]
const char *strchr(const char *s, int c); [C++ only]
char *strchr(char *s, int c); [C++ only]
int strcmp(const char *s1, const char *s2);
int strcoll(const char *s1, const char *s2);
char *strcpy(char *s1, const char *s2);
size_t strcspn(const char *s1, const char *s2);
char *strerror(int errcode);
size_t strlen(const char *s);
char *strncat(char *s1, const char *s2, size_t n);
int strncmp(const char *s1, const char *s2, size_t n);
char *strncpy(char *s1, const char *s2, size_t n);
char *strpbrk(const char *s1, const char *s2); [not in C++]
const char *strpbrk(const char *s1, const char *s2); [C++ only]
char *strpbrk(char *s1, const char *s2); [C++ only]
char *strrchr(const char *s, int c); [not in C++]
const char *strrchr(const char *s, int c); [C++ only]
char *strrchr(char *s, int c); [C++ only]
size_t strspn(const char *s1, const char *s2);
char *strstr(const char *s1, const char *s2); [not in C++]
const char *strstr(const char *s1, const char *s2); [C++ only]
char *strstr(char *s1, const char *s2); [C++ only]
char *strtok(char *s1, const char *s2);
size_t strxfrm(char *s1, const char *s2, size_t n);

Please ... if you are familure with any of them ...
can you write something about it Please....
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-11-2002, 03:53 PM   #10
Registered User
 
Join Date: Apr 2002
Posts: 249
Sorry.... This Theard about ....

This Theard about Strings function in C++...
As a beginner programmers in C++, we need to know something about String functions... So
I did ask you to send me some String functions... in the time that I was looking for these function too....
So I found alot of funcitons, which I could andersand some of it ... but I will need to understand more about it ....

is that answer your Question ???
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-11-2002, 05:58 PM   #11
Registered User
 
Join Date: Oct 2001
Posts: 2,936
Here's a good thread about strspn() and strcspn().

http://www.cprogramming.com/cboard/s...hlight=strcspn
swoopy is offline   Reply With Quote
Old 04-11-2002, 06:09 PM   #12
Code Goddess
 
Prelude's Avatar
 
Join Date: Sep 2001
Posts: 9,661
http://www.dinkumware.com/htm_cl/string.html

-Prelude
__________________
My best code is written with the delete key.
Prelude is offline   Reply With Quote
Old 04-12-2002, 03:37 PM   #13
Registered User
 
Join Date: Apr 2002
Posts: 249
Thanks .. I need to collect them all

Please if you can help me collecting them all in this thread ....
__________________
C++
The best
NANO is offline   Reply With Quote
Old 04-12-2002, 08:31 PM   #14
Unregistered
Guest
 
Posts: n/a
that is ridiculous. Please do not clutter the board with trash. Go to the GNU C documentation at http://www.aquaphoenix.com/ref/gnu_c_library/
  Reply With Quote
Old 04-12-2002, 08:35 PM   #15
Code Goddess
 
Prelude's Avatar
 
Join Date: Sep 2001
Posts: 9,661
>Please if you can help me collecting them all in this thread ....
I gave you them all, so stop bumping this lame thread.

-Prelude
__________________
My best code is written with the delete key.
Prelude is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strings Program limergal C++ Programming 4 12-02-2006 03:24 PM
Problem with Strings, Please help! varus C++ Programming 8 11-27-2006 11:47 PM
Programming using strings jlu0418 C++ Programming 5 11-26-2006 08:07 PM
Reading strings input by the user... Cmuppet C Programming 13 07-21-2004 06:37 AM
menus and strings garycastillo C Programming 3 04-29-2002 11:23 AM


All times are GMT -6. The time now is 01:42 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22