The purpose is to simply to generate psuedo-random numbers using time like I am doing. That is it. Nothing more. Regardless of what I am doing with the result -- it is part of a bigger project. This...
Type: Posts; User: towed
The purpose is to simply to generate psuedo-random numbers using time like I am doing. That is it. Nothing more. Regardless of what I am doing with the result -- it is part of a bigger project. This...
Will this generate psuedo random numbers efficiently?
Idea: I want it to cycle through a user defined number of numbers (n_total) for as long as it takes to reach a set criteria of numbers that...
Yeah I get -20... But how can I get 340? That is the right answer (i.e., from google).
Problem with Modulus
I am doing fmod(-20, 360) and not getting the correct answer (340).
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
Hello,
I am trying to write some code to do a linear interpolation scheme along an 360 element array (so 0 - 359 elements with each element representing a degree, aka like on a compass). I have...
Very interesting site... I see the use of "rand()/((double)RAND_MAX + 1)" there...
No biggie... its not my full code, as that in itself is very long...
That is what I meant, sorry!
Well, I will be running it for multiple cases and want different lists. Thus, seeding the PRNG (psuedo-random number generator I assume you are referring to) with time. Its just that, although the...
so pass iseed in instead of doing it in the function?
any reason why it is bad to seed it in the function?
I have made a function that generates a random number and, from that number, pulls a name from a list if criteria is met. BUT, I am questioning its capability. I know with computers, the numbers...
Yes... That's one of the reasons I said foolish :P...
Ughh...
Check with:
if(file == NULL) printf("fail");
?
Im running a program that takes several days to run and think I know the cause... I didnt run it in gdb so I have no idea exactly besides a hint at where it is. Is this a possible cause?
Looking...
How can strlen(ptr_str)+1 become 0. Doesn't strlen have to be positive?
tag.
Well the aforementioned freeing seems like it worked, given that it now has passed that point in the program. Thanks tabstop :)... I think I learned a thing or two with this discussion.
Yeah, I have it print strlen() when it fails and it returned 3. So, I THINK it is safe to say its memory leak or not enough being present. Could it be that conclusive (in regard to the diagnoses).
Interesting... Sadly, I never thought this could/would occurred. I always (that I remember) am freeing memory after every malloc (including in this function since it is called MANY times. Which...
Testing for the error message w/
wx_second = malloc(strlen(ptr_str) + 1);
if(wx_second == NULL){
printf("** Error in...
(gdb) down
#2 0x08053734 in madis_wx_intensity (pres_weath=0x81163bb "-RA", ' ' <repeats 21 times>, auto_stn_type=0x813ddb2 " ", pass=1, precip1=0x2d,
precip2=0x2d, precip3=0x2d,...
2623 is the strcpy()...
Sorry, I don't what you mean by "missing line".
Ok, I did that and got:
(gdb) up
#1 0x00000000 in ?? ()
(gdb) up
#2 0x08053734 in madis_wx_intensity (pres_weath=0x81163bb "-RA", ' ' <repeats 21 times>, auto_stn_type=0x813ddb2 " ",...
Hmm, well -g is an option at least.
#0 0x881663f0 in strcpy () from /lib/libc.so.6
#1 0x00000000 in ?? ()
#2 0x08053734 in madis_wx_intensity (pres_weath=0x81163bb "-RA", ' ' <repeats 21 times>, auto_stn_type=0x813ddb2 " ",...
IF it is non-writable memory, anyway to fix it? Get more memory in my heap (I use malloc() so it isn't my stack, correct?... or I believe).
Note, It's weird as I modified this function before and...
In regards to 2, that is so weird. As before that step I check the what is pass for NULL via:
char *ptr;
...
ptr = strstr(string, wx_element);
so you have to compile with -g to get it? It doesn't just add it when using gdb? I use -Wall...