Originariamente inviato da gianvituzzi
si ma continuo ad avere errore quì:
codice:
stampa(const std::map<int, int>& hashChunk, int dwNumChunks)
"Posta" esattamente il codice che ti da errore, e se puoi anche l'errore, meglio anche se la versione del compilatore e del sistema operativo che stai usando:
ad esempio con il seguente compila con zero errori zero warning (ho eliminato l'argomento non più utilizzato di stampa "int dwNumChunks")
codice:
/*
Compiled using:
$ g++ --version
i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)
Command:
$ g++ -Wall -ansi -pedantic -Wextra -Wconversion main.cpp
Output:
$ ./a.out
0 -> 2304
1 -> 2304
2 -> 2304
3 -> 2304
{...omissis..}
41 -> 2304
42 -> 2304
43 -> 928
*/
#include <stdlib.h>
#include <map>
#include <math.h>
static
bool stampa(const std::map<int, int>& hashChunk);
int main()
{
std::map<int, int> hashChunk;
int dwBuffer = 100000;
int dwChunk = 2304;
int dwNumChunks = (int)ceil((double)dwBuffer/dwChunk);
int dwLastChunk = dwChunk-((dwChunk*dwNumChunks)-dwBuffer);
int k = 0;
while (k < dwNumChunks - 1)
{
hashChunk.insert(std::make_pair(k, dwChunk));
++k;
}
hashChunk.insert(std::make_pair(k, dwLastChunk));
stampa (hashChunk);
// system("pause");
return 0;
}
static
bool stampa(const std::map<int, int>& hashChunk)
{
for (std::map<int, int>::const_iterator aIter = hashChunk.begin (); aIter != hashChunk.end (); ++aIter){
printf("%d -> %d\n", aIter->first, aIter->second);
}
return true;
}