the first segment of code also uses string literals, it doesn't give me any segmentation fault...confused..
Type: Posts; User: skyglin
the first segment of code also uses string literals, it doesn't give me any segmentation fault...confused..
void concat(char *s1, const char *s2)
{
char *p = s1;
while (*p) ++p;
while (*p++ = *s2++) ;
}
this will work, but the numbers generated are not uniformaly distributed in the interval [-1, 1), almost all the points lies in [-1, -0.9) if 1000000 numbers are generated.
what I did was first...
Thanks, I see.
Now my problem is what I should modify so it will generate floating numbers between -1 to 1 using X(n+1) = (X(n) + X(n-1)) % 1.0. The initial two points must be in the interval [0, 1).
I did try with *nodePtr = fmod(*temp_x1 + *temp_x2, 1.0); but the 1000000 floating-point numbers generated are all in the interval [0, 1.0), so times 2 and subtract 1 should give me a result between...
For this program, I want to generate a floating point number in the interval [-1, 1] using the formular X(n+1) = (X(n) + X(n-1)) % 1.0, however, when I print out the numbers it generated, it printed...
>>>void foo( data_type array[SIZE] )
when defining this function, do I must specify the array size as SIZE (here it corresponds to number of columns) ?
Let's say I have 2D array of N rows and M columns, how do pass one of the rows of this array to a function and the function can use this row as a 1D array? Thanks.
yes, it's a status message, are there any functions to do that?
Sorry, I'm not quite understanding, can you show me a sample code, I think it's much easier to understand from codes. Thanks
I have been working on a program that calculates the minimum potential of a number of particles, the amount of time the program runs can be specifed by the user. Since the user can have the program...
What are some of the uses of passing "pointer to constants"( int const *ci1; ) as parameters to a function? A simple example would be nice. Thanks
>>>what a union does is makes a data type whose members share the same physical memory space.
How does the compiler handle the memory space if the memebers of a union occupy memory in different...
thanks, enumerated type is what I was looking for..
and by the way, I haven't learned union, how do I use it?
Since C doesn't have boolean type, I'm trying to use typedef to create a boolean data type. How do I use structure to create such boolean type (I saw somewhere, but I forgot) ?
typdef int...
I just want to do some simple graphics components like buttons, panel, textfields and some simple 2D graphics. Which graphic library is good and simple to use?
Does OpenGL include something similar to the swing library in JAVA (JButton, JTextField, JPanel, JFrame....etc)?
I'm kinda new to C programming, I was just wondering if C can do graphics like JAVA or C++? Are there any free graphics library for C out there?
Thanks, this is what I needed. yeah!!
thanks. I understand it now.
My program has a matrix of floating point values, after I performed calculations to each element in the matrix, when I print out using printf() some of the elements turned out to have the value...
>>int main( int argc, char *argv[] )
ok this is one of the standard, my question is that why do we pass two arguments to the main function, one as an int and one as a pointer to a char array. What...
Thank you for your guys' help. This site is really helpful!
sorry, it's local/non-static.
I have tried global and it worked. Is there any way to make it work as a local array?
How come global works but not local?
Thanks a lot!
I have used MS Visual C++ 6.0, GCC, and MPICC to compile. Only worked with small sized arrays.