Dear all,
Why this program, cannot compile?
Compiling...
90.cpp
C:\Documents and Settings\Admini strator\Desktop \MASTER\90.cpp( 2) : error C2871: 'std' : does not exist or is not a namespace
C:\Documents and Settings\Admini strator\Desktop \MASTER\90.cpp( 8) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
90.exe - 2 error(s), 0 warning(s)
[code=cpp]
#include <iostream.h>
using namespace std;
const int COL = 3;
const int ROW = 3;
int main(int argc, char *argv[]);
{
int i;
int time;
int srand,NULL,rand ;
int matrix[COL][ROW] = {0}; // declare and initialize a 2d array
// seed the random number generator
// with the current time
srand( (unsigned)time( NULL ) );
// loop through the 2d array
// assigning a random number
for (int i = 0; i < COL; i++)
{
for (int j = 0; j < ROW; j++)
{
matrix[i][j] = rand();
}
}
// print the matrix
for (int i = 0; i < COL; i++)
{
for (int j = 0; j < ROW; j++)
{
printf("%d\t", matrix[i][j]);
}
printf("\n");
}
return 0;
}[/code]
Why this program, cannot compile?
Compiling...
90.cpp
C:\Documents and Settings\Admini strator\Desktop \MASTER\90.cpp( 2) : error C2871: 'std' : does not exist or is not a namespace
C:\Documents and Settings\Admini strator\Desktop \MASTER\90.cpp( 8) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
90.exe - 2 error(s), 0 warning(s)
[code=cpp]
#include <iostream.h>
using namespace std;
const int COL = 3;
const int ROW = 3;
int main(int argc, char *argv[]);
{
int i;
int time;
int srand,NULL,rand ;
int matrix[COL][ROW] = {0}; // declare and initialize a 2d array
// seed the random number generator
// with the current time
srand( (unsigned)time( NULL ) );
// loop through the 2d array
// assigning a random number
for (int i = 0; i < COL; i++)
{
for (int j = 0; j < ROW; j++)
{
matrix[i][j] = rand();
}
}
// print the matrix
for (int i = 0; i < COL; i++)
{
for (int j = 0; j < ROW; j++)
{
printf("%d\t", matrix[i][j]);
}
printf("\n");
}
return 0;
}[/code]
Comment