473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Compiler errors

Dear all,

Why this program, cannot compile?

Compiling...
90.cpp
C:\Documents and Settings\Administrator\Desktop\MASTER\90.cpp(2) : error C2871: 'std' : does not exist or is not a namespace
C:\Documents and Settings\Administrator\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)
Expand|Select|Wrap|Line Numbers
  1. #include <iostream.h>
  2. using namespace std;
  3.  
  4. const int COL = 3;
  5. const int ROW = 3;
  6.  
  7.     int main(int argc, char *argv[]);
  8. {
  9.     int i;
  10.     int time;
  11.     int srand,NULL,rand;
  12.     int matrix[COL][ROW] = {0};   // declare and initialize a 2d array
  13.  
  14.     // seed the random number generator 
  15.     // with the current time
  16.     srand( (unsigned)time( NULL ) );
  17.  
  18.     // loop through the 2d array 
  19.     // assigning a random number
  20.     for (int i = 0; i < COL; i++)
  21. {
  22.     for (int j = 0; j < ROW; j++)
  23. {
  24.             matrix[i][j] = rand();
  25. }
  26. }
  27.  
  28.     // print the matrix
  29.     for (int i = 0; i < COL; i++)
  30. {
  31.     for (int j = 0; j < ROW; j++)
  32. {
  33.             printf("%d\t", matrix[i][j]);
  34. }
  35.         printf("\n");
  36. }
  37.     return 0;
  38. }
Oct 5 '07 #1
3 1196
oler1s
671 Expert 512MB
The program can't compile because there are syntax errors.

#include <iostream.h> : Deprecated. Use <iostream> instead. If you don't understand why, then whatever resource you used to learn C++ is outdated. Get C++ Primer by Lippman, Accelerated C++ by Koenig, or another recognized and well recommended book.

Of course, you never use anything within iostream. Interestingly, this looks like an attempt at taking some C code and patching it as C++. Because you use srand (without the appropriate header). The same goes for printf, which is in cstdio in C++. But why use printf if you include <iostream>.

You have aroused my suspicions, so I think you'll want to explain what is going on here.
Oct 5 '07 #2
I have done acoretion, but still have error...anybody can tell me to correct its.?
:\Documents and Settings\Administrator\Desktop\MASTER\90.cpp(20) : error C2064: term does not evaluate to a function
C:\Documents and Settings\Administrator\Desktop\MASTER\90.cpp(20) : error C2064: term does not evaluate to a function
C:\Documents and Settings\Administrator\Desktop\MASTER\90.cpp(21) : error C2064: term does not evaluate to a function
C:\Documents and Settings\Administrator\Desktop\MASTER\90.cpp(25) : error C2086: 'i' : redefinition
C:\Documents and Settings\Administrator\Desktop\MASTER\90.cpp(34) : error C2086: 'i' : redefinition
Error executing cl.exe.

90.exe - 5 error(s), 0 warning(s)

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main ()
{

const int COL = 3;
const int ROW = 3;

int main(int argc, char *argv[]);
{
int i;
int time;
int srand;
int matrix[COL][ROW] = {0}; // declare and initialize a 2d array

// seed the random number generator
// with the current time
srand( (unsigned)time( NULL ) );
srand ( 1 );

// 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;
}
}
Oct 7 '07 #3
JosAH
11,448 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. int main ()
  2. {
  3.  
  4. const int COL = 3;
  5. const int ROW = 3;
  6.  
  7.     int main(int argc, char *argv[]);
  8. {
  9.     int i;
  10. // etc.
  11.  
What are you trying to accomplish here?

kind regards,

Jos
Oct 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: jon morgan | last post by:
OK, I'm going to be brave. There is a bug in VS.Net 1.1 that causes random compiler errors. I have raised this issue in posts at least three time in the past couple of months without attracting...
30
by: Neil Zanella | last post by:
Hello, Allow me to share my frustrations with GNU g++. This is the second time something similar happens to me: I can't find anything wrong with my C++ program and yet I get segfaults, and...
10
by: Bjorn | last post by:
I'm using interfaces in C++ by declaring classes with only pure virtual methods. If then someone wants to implement the interface they needs to inherit from the class. If the implementing class...
2
by: Mary | last post by:
Hello, I am having a problem with the cl compiler. I have written a C class (RegConnect.c) which uses Win32 API functions such as RegOpenKey, RegCloseKey etc. Initially when I was trying to...
16
by: pj | last post by:
(Was originally, probably wrongly, posted to the vc subgroup.) (This doesn't appear to be a c# problem, but a problem with a bug in the Visual Studio c# compiler, but, any help will be welcome...)...
6
by: David Lack | last post by:
Hi, I recently installed a 60-day trial of .NET 2003 on my development system. I made tests with previous personal projects (which compiled ok with VC6) and some open source files, and keep...
2
by: Samuel R. Neff | last post by:
Within the past few weeks we've been getting a lot of compiler errors in two classes when no errors actually exist. The error always reports as Name '_stepResizeRelocator' is not declared. ...
1
by: Peter Wilson | last post by:
I am running a VB.Net conversion project and have run into a severe problem compiling the application. The project has a main project with about one hundreds forms. (Did I say badly structured?) ...
14
by: 2005 | last post by:
Would it suppress errors? Is he trying to hide errors in his code?
8
by: =?GB2312?B?yum09MXt?= | last post by:
today I forgot to include some header,then I found the error message by the compiler is quite strange. so I want to know exactly the inner details of the compiler impletation,if possible. and I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.