Quote Originally Posted by revve View Post
Code:
#include <iostream> 
using std::cout; 
using std::endl; 
 
#include <cstdlib> 
#include <ctime> 
 
#include <iomanip> //In this line, compiler gives warning C4067: unexpected tokens following //preprocessor directive - expected a newline but program still executes instead of this. //What is the reason of this error? How can I fix it?
using std::setw; 
 
using namespace std;
Have you tried moving the using directives to after the includes?

Quote Originally Posted by revve View Post
Another question,

I have the following code in my constructor:

Code:
srand(int(time(NULL))); 
for(int i=0; i<(99-1); i++){ //shuffling card; 
 
int r = i + (rand() &#37; (99-i)); // Random remaining position. 
int temp = kartSayilar; 
kartSayilar = kartSayilar[r]; 
kartSayilar[r] = temp; 
}
The aim of this is to shuffle numbers in the kartSayilar array randomly. I creates two objects of this in a different .cpp file but when program executes, both objects have the same random numbers. I think my srand function doesn't work. How can i fix it?
Where is the index to kartSayilar on the third line in the for loop? I think you want:
Code:
srand(int(time(NULL))); 
for(int i=0; i<(99-1); i++){ //shuffling card; 
 
    int r = i + (rand() % (99-i)); // Random remaining position. 
    int temp = kartSayilar[i]; 
    kartSayilar[i] = kartSayilar[r]; 
    kartSayilar[r] = temp; 
}
-Erik