| Thaity (3) | |||
|
Hi Guys. I'm doing an assignment for uni, and I'm getting a message I don't understand. I've researched other examples, and I don't see a difference, perhaps someone can shed some light. The assignment involves a random number generator and bubble sort. - The error message is,"Warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data"
Thank-you in advance. | |||
|
|
|||
| Chervil (1205) | |
|
That isn't an error, it's just a warning. You should be able to ignore it. Function time() returns a value of type time_tFunction srand() takes a parameter of type unsigned intThe compiler automatically converts from one to the other, and is simply letting you know that there may be some loss of precision. If considered necessary, you could suppress the message by using an explicit cast, using either srand((unsigned int) time(0));or srand(static_cast<unsigned int>(time(0)));
| |
|
Last edited on
|
|
| Thaity (3) | |
|
Thank - you Chervil, spot on. If I could ask about one more error message... "error LNK2019: unresolved external symbol "void __cdecl bubblesort(void)" (?bubblesort@@YAXXZ) referenced in function _main" I have no idea about this? A Google search says I may be missing a library, I just have no idea which one? | |
|
|
|
| ne555 (4383) | |
|
You say bubblesort does not take any argument You use bubblesort without passing any parameters You define a bubblesort that must take an array and its size as parameters. ¿see the problem? You should learn about scope By the way, `random' is not a good name for the size of an array. | |
|
Last edited on
|
|
| Chervil (1205) | |
In your code above, you have defined function bubblesort at line 60 like this:void bubblesort(int randqty[], int random)That is, it requires two input parameters, the first is an array of integers, the second is an integer. However, the declaration on line 9 void bubblesort();is a function which takes no parameters at all. As far as the compiler is concerned, these are two different functions. On line 40, the function is called, with no parameters. The compiler thinks this is ok, as it matches the declaration on line 9. But the linker tries to match the function call to the code or the function, but cannot find it. Hence it is the linker which outputs the error message. In this case, it looks like the correct version is the one on line 60. You need to change both the prototype declaration (line 9) and the call on line 40, so they each supply the required parameters, so as to agree with line 60. Here's a recent thread where the role of the prototype is discussed in a bit more detail: http://www.cplusplus.com/forum/beginner/88749/#msg476413 | |
|
|
|
| Thaity (3) | |
| Thank-you once again, all input is greatly appreciated. | |
|
|
|