initializing

Dynamically allocating and setting to zero an array of floats

Hi How do I automatically set a dynamically allocated array of floats to zero(0.0) during allocation Is this OK float* delay_line = new float[filter_len]; //THIS memset(delay_line, 0.0, filter_len); //can I do this for a float?? //OR THIS for (int i = 0; i < filter_len; i++) delay_line[i] = 0.0; Which is the most efficient way ...

c sharp initialzing an integer data type

how to initialize a variable of data type integer, in c sharp. the problem is the variable has to store an integer with values ranging from 1 to 4. ...

'Bracket initializing'. (C++)

I'm learning C++ at the moment, C++ Primer plus. But I just felt like checking out the cplusplus website and skip a little forward to file handling. I pretty much know the basics of file handling coming from java, php, visual basic. But I came across a pretty weird line. ostream os(&fb); fb represents a filebuf. I just don't get the ...

How to make my Java destop application show an image before it starts?

I'm using NetBeans IDE 6.8 (Mac Version). which tool of their GUI builder will assist me in doing this? What I want is is to show the user an image while my application is loading for couple of seconds before I show him the application. How can I do that? initializing ...

NSTextView doesn't initialize when I call readFromData:(NSData *)data ofType:(NSString*)string

I have a refreshDisplay: method that calls the setString: method of an NSTextView. I can save, and load, but when I load even though my program loads the data, it does not display it on the NSTextView as it should. I did a check and that NSTextView seems to be nil when I load, which is why the setString: method does not do anything to it...

"Initializing" the pointer in the separate function in C

I need to do a simple thing, which I used to do many times in Java, but I'm stuck in C (pure C, not C++). The situation looks like this: int *a; void initArray( int *arr ) { arr = malloc( sizeof( int ) * SIZE ); } int main() { initArray( a ); // a is NULL here! what to do?! return 0; } I have some "initializing" fun...

initializing structs using user-input information

I am trying to make a program that works with poker (texas holdem) starting hands; each hand has a value from 1 to 169, and i want to be able to input each card and whether they are suited or not, and have those values correspond to a series of structs. Here is the code so far, i cant seem to get it to work (im a beginning programmer). ...

Structure initialization as argument

I try to send some struct into STL list; struct obj { int a; int b; } list < struct obj> mylist; struct obj a = { 0, 1}; mylist.push_back ( a); Is there any other way to initialize argument of push_back? For example: mylist.push_back ( struct obj a ={0, 1}); g++ tells me: expected primary-expression before "struct"; ...