DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   extracting info to another array (http://www.daniweb.com/forums/thread112185.html)

mrjoli021 Mar 4th, 2008 5:51 pm
extracting info to another array
 
I have some sentences in a 2 dimensional char array. I need to change to first letter of each sentence to caps. I was thinking of removing the first char and placing it into 1 array and the rest of the sentence into another array. run toupper on the first array and then print them both out. my question is how do I populate 1 array to the other??

Ancient Dragon Mar 4th, 2008 6:14 pm
Re: extracting info to another array
 
why use two different character arrays when you can do it directly in the original, assuming the original is not string literals
char str[] "hello world";
str[0] = toupper(str[0]);

mrjoli021 Mar 4th, 2008 6:59 pm
Re: extracting info to another array
 
ok so now how do I print the entire sentence.

int i;
                       
        for (i = 0; i < FIindex; i++)
        {
                fragments[i][0] = toupper(fragments[i][0]);
                std::cout << fragments << endl;
        }

mrjoli021 Mar 4th, 2008 7:00 pm
Re: extracting info to another array
 
go it working.

thanks

Ancient Dragon Mar 4th, 2008 7:02 pm
Re: extracting info to another array
 
>>std::cout << fragments << endl;

should be this:
std::cout << fragments[i] << endl;


All times are GMT -4. The time now is 3:37 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC