Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays and Letters

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need to write a small program that will assign the letter 'S' to an array a number of times, depending on how many times I ask for;;
That means if I chose number 5, then the program will assign S five times inside the array "let's say array[0]" so array[0]=SSSSS

Thanks
 
well, if you know the size of the array

say size = 7

char* array = new array[size+1];
memset(array,'S',size);
array[size]=0;

Matt
 
If you just want to repeat the letter N times, you can use the string class:
Code:
    #include <string>

    int iCount = 20;
    char chLetter = 'S';

    std::string strData(iCount, chLetter);
HTH
Shyan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top