C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-26-2008, 11:20 PM   #1
Registered User
 
Join Date: Sep 2008
Posts: 58
Need help.. beginner

I have an array, and I malloc'd memory for it already, how do I set all the slots to spaces?
Code:
char **array;

array = (char **) malloc blabla
for(i = 0;loop){
array[i] = (char *) malloc again..
//HERE// array[i] = {ALL SPACES??}
}
scarlet00014 is offline   Reply With Quote
Old 09-27-2008, 04:08 AM   #2
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Code:
memset(memory, ' ', size)
will fill size bytes of whatever is pointed to by memory with ' ', which is space.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.

Last edited by matsp; 09-27-2008 at 04:19 AM.
matsp is offline   Reply With Quote
Old 09-27-2008, 04:11 AM   #3
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
http://faq.cprogramming.com/cgi-bin/...&id=1043284351
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Reply

Tags
array, arrays, beginner

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Same old beginner question... Sharmz C Programming 15 08-04-2008 11:48 AM
What are some good beginner programs I shouold make? oobootsy1 C# Programming 6 08-09-2005 02:02 PM
Books, Beginner, MustHave Zeusbwr C++ Programming 9 10-25-2004 05:14 PM
Windows programming for beginner (Absolute beginner) WDT Windows Programming 4 01-06-2004 11:21 AM


All times are GMT -6. The time now is 01:36 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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