Is there the same function in c++ as FILLCHAR in Pascal?

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
oldbam
New poster
Posts: 17
Joined: Tue Sep 14, 2004 9:30 am

Is there the same function in c++ as FILLCHAR in Pascal?

Post by oldbam »

Is there the same function in c++ as FILLCHAR in Pascal?
How to fill the array will special value quickly?
Life is beautifull !!!
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

Try something like[cpp]string s(100, 'a');[/cpp]
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

If you want to initiate all bytes in char array the same character you could use memset() function :-)

Code: Select all

memset(array,fill_this_character,sizeof(array));
Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
oldbam
New poster
Posts: 17
Joined: Tue Sep 14, 2004 9:30 am

Post by oldbam »

And what about non-char array?
Life is beautifull !!!
Krzysztof Duleba
Guru
Posts: 584
Joined: Thu Jun 19, 2003 3:48 am
Location: Sanok, Poland
Contact:

Post by Krzysztof Duleba »

Use vector. To create a vector v with 100 entries of 2.5, write
[cpp]vector<double> v(100, 2.5);[/cpp]
oldbam
New poster
Posts: 17
Joined: Tue Sep 14, 2004 9:30 am

Post by oldbam »

Great thanks! :lol:
Life is beautifull !!!
Post Reply

Return to “C++”