Strings are V important...

This is a discussion on Strings are V important... within the C++ Programming forums, part of the General Programming Boards category; Dears, As a Begginer student for C++, I know something about it but Please do us a favor. Students will ...

  1. #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

  2. #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

  3. #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

  4. #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

  5. #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

  6. #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

  7. #7
    Unregistered
    Guest
    Anyone know what this thread is all about?

  8. #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

  9. #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

  10. #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

  11. #11
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Here's a good thread about strspn() and strcspn().

    http://www.cprogramming.com/cboard/s...hlight=strcspn

  12. #12
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    My best code is written with the delete key.

  13. #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

  14. #14
    Unregistered
    Guest
    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/

  15. #15
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >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.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

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

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