Ok friends, I found it: The correct names are :rand(int) and srand().
Thank you.
User Profile
Collapse
-
David727 replied to why doesn't the compiler recognize the function although I included the right libs?in CWhen I try to run it, I fail and get a message error that "The system cannot finf the file specified".
Allright then, I wrote now all the errors I got (not only the 2 I wrote before).
error LNK1120: 2 unresolved externals
error LNK2019:unresol ved external symbol_random referenced in function_main
error LNK2019:unresol ved external symbol_randomiz e referenced in function_main ...Leave a comment:
-
David727 replied to why doesn't the compiler recognize the function although I included the right libs?in CThanks for the answer Banfa but
1.By your explanation I should pass the compiler phase--and I didn't. The fail wasn't in the Run phase but in the compiler phase.
2. As much as I know, random function belongs to stdlib library. If not...Do you know about another library it belongs to?Leave a comment:
-
David727 started a topic why doesn't the compiler recognize the function although I included the right libs?in Cwhy doesn't the compiler recognize the function although I included the right libs?
this is the code
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main () {
int b ;
randomize () ;
b = random (61) + 40 ;
printf ("This is b: %d\n", b ) ;
}
These are the errors:
error LNK2019:unresol ved external symbol_random referenced in function_main
error LNK2019:unresol ved external symbol_randomiz e... -
David727 replied to Why is the gap between an address of a file pointer, to the one after it, is only 32in CUntill yesterday I was sure that
the file pointer points to the file, but it only points to the structure (it explains a lot).
The gap of 32 bytes is only the size of the structure (FILE)-
-I checked with sizeof and the result was 32- not the size of the file try1.txt (which its data is in another place - the hard drive).
Man you helped me a lot. Thank you.Leave a comment:
-
David727 replied to Why is the gap between an address of a file pointer, to the one after it, is only 32in C"The only reliable way to determine the size of a data type is with the sizeof operator".
I thought that when I use sizeof(f), I get the size of the pointer cell, and when I use sizeof(*f) I get the size of the data inside the text file but now I understand that sizeof (*f) is only a size for the structure. ok..
so how can I know the size of the data inside the text file? I mean sizeof(what).
Is the only way...Leave a comment:
-
David727 replied to Why is the gap between an address of a file pointer, to the one after it, is only 32in CHi,
You were right about the 32 : these are bytes and not bits.
Ok, so let’s look at the value of f.
(f is a pointer to try1.txt file).
The value is the memory address of try1.txt.
Now let’s look at the value of g.
(g is a pointer to try2.txt file).
The value is the memory address of the try2.txt.
The gap between the values of f and g is 32.
When I...Leave a comment:
-
David727 replied to Why is the gap between an address of a file pointer, to the one after it, is only 32in CHi, I used your advice and it was very helpful.
The results were very interesting (by the way, for your question why do I want to know that, the answer is only from a pure curiosity about where and how all the variables are saved).
ok so that is the case: the size of all the addresses is 4. it means that our friend Weaknessforcats was right.
32 represents bits and not bytes.
NOW, there is another way to look at it and...Leave a comment:
-
David727 replied to Why is the gap between an address of a file pointer, to the one after it, is only 32in CThank you.
OK, I don't want to know (for now) the size of the data (the size of the file), but only the size of the memory unit of the pointer itself.
I have now 2 different answers for that:
The first answer is that 32 is a gap of 4 bytes (every byte is a 8 bit unit which means that 32 is 32 bits).
(thanks Weaknessforcats ).
The second answer is that the gap of 32 is 32 bytes (and not bits)....Leave a comment:
-
David727 started a topic Why is the gap between an address of a file pointer, to the one after it, is only 32in CWhy is the gap between an address of a file pointer, to the one after it, is only 32
#include<stdio. h>
char garb;
FILE *f ,*g;
int main(){
f=fopen("try1.t xt","wt");
g=fopen("try2.t xt","wt");
printf("f is equal to %ld\n",f);
//the result is 2009464032
printf("g is equal to %ld\n",g);
//the result is 2009464064
//I...
No activity results to display
Show More
Leave a comment: