DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: how to convert a string's content into the uppercase.

  1. #1
    jwr001 Guest

    how to convert a string's content into the uppercase.


    Who knows how to convert a string's content into the uppercase?

    thank you very much.

  2. #2
    Wreakon Guest

    Re: how to convert a string's content into the uppercase.


    "jwr001" <wji@uncc.edu> wrote:
    >
    >Who knows how to convert a string's content into the uppercase?
    >
    >thank you very much.


    std::String = "aBx";
    String.toupper();

    or

    String.ToUpper();

    it was something like this.


  3. #3
    Danny Kalev Guest

    Re: how to convert a string's content into the uppercase.

    apply toupper() to each char in the string.

    Danny

    jwr001 wrote:
    >
    > Who knows how to convert a string's content into the uppercase?
    >
    > thank you very much.


  4. #4
    shawan sweden Guest

    Re: how to convert a string's content into the uppercase.


    "jwr001" <wji@uncc.edu> wrote:
    >
    >Who knows how to convert a string's content into the uppercase?
    >
    >thank you very much.


    This is for C program.

    if you have character strings 'A','B','C',....'Z' and 'a','b','c',....'z'


    the ASCII code for them are:-

    'A' = 65 'a' = 97
    'B' = 66 'b' = 98
    . .
    . .
    . .
    'Z' = 90 'z' = 122


    the diffrence beteeen lowercase 'a' and upercase 'A' is delta

    delta = 97 - 65 = 32

    to conver from low to upp case:-

    char x='a';

    printf(" x= %d \n",x);

    printf(" x= %d \n",x-32);

    printf(" x= %c \n",x-32);

    output is:-

    x = 97
    x = 65
    x = 'A'





  5. #5
    Al Guest

    Re: how to convert a string's content into the uppercase.


    Hi,

    if you are using VC++ there is a cool solution for this problem.

    //...
    CString csUpper; // it will contain the string as uppercase
    char* cs = "it in uppercase"; // text

    csUpper = cs; // CString object now has your string
    csUpper.MakeUpper(); // turning it as uppercase
    printf("%s\n",csUpper); // showing it on the screen
    //...

    Note : Your project must support MFC


  6. #6
    ralph Guest

    Re: how to convert a string's content into the uppercase.


    "jwr001" <wji@uncc.edu> wrote:
    >
    >Who knows how to convert a string's content into the uppercase?
    >
    >thank you very much.


    _strupr()

    * Note: It will not work with a literal constant string without a strdup(),
    use only with buffers.

  7. #7
    James Curran Guest

    Re: how to convert a string's content into the uppercase.

    The answer to that is not as easy as you might guess. The first thing
    we need to know is exactly what do you mean by "a string"?

    A C++ std::string?
    An MFC CString?
    A C string (NUL terminated array of characters)?

    After we decided that, then we need to know is we're deal with just
    English, or do we have to consider other languages as well?

    For each of those, the answer is quite different.

    --
    Truth,
    James Curran
    www.NJTheater.com (Professional)
    www.NovelTheory.com (Personal)
    www.BrandsForLess.Com (Day Job)


    "jwr001" <wji@uncc.edu> wrote in message news:3bd4b8c8$1@news.devx.com...
    >
    > Who knows how to convert a string's content into the uppercase?





  8. #8
    Prototype Guest

    Re: how to convert a string's content into the uppercase.


    "jwr001" <wji@uncc.edu> wrote:
    >
    >Who knows how to convert a string's content into the uppercase?
    >
    >thank you very much.



    I found a nice case-insensitive strcmp somewhere, but I can`t remember where.
    It was just some source code to put in your string.h file.


  9. #9
    James Curran Guest

    Re: how to convert a string's content into the uppercase.

    "Prototype" <prototype@myself.com> wrote in message
    news:3bd88b01$1@news.devx.com...

    > I found a nice case-insensitive strcmp somewhere, but I can`t remember

    where.
    > It was just some source code to put in your string.h file.
    >


    There is no standard one, but most compilers offer one as an extension.
    However, they can't agree on a name. Some use stricmp(), other use
    strcmpi(), and still others use istrcmp().

    --
    Truth,
    James Curran
    www.NJTheater.com (Professional)
    www.NovelTheory.com (Personal)
    www.BrandsForLess.Com (Day Job)






  10. #10
    ralph Guest

    Re: how to convert a string's content into the uppercase.


    "James Curran" <JamesCurran@mvps.org> wrote:
    >"Prototype" <prototype@myself.com> wrote in message
    >news:3bd88b01$1@news.devx.com...
    >
    >> I found a nice case-insensitive strcmp somewhere, but I can`t remember

    >where.
    >> It was just some source code to put in your string.h file.
    >>

    >
    > There is no standard one, but most compilers offer one as an extension.
    >However, they can't agree on a name. Some use stricmp(), other use
    >strcmpi(), and still others use istrcmp().
    >
    >--
    >Truth,
    >James Curran
    >www.NJTheater.com (Professional)
    >www.NovelTheory.com (Personal)
    >www.BrandsForLess.Com (Day Job)
    >


    And leave us not forget... _tcsicmp(), _mbsicmp(), and _wcsicmp(). <g>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center