Sponsored Content
Full Discussion: Please Help!
Top Forums Programming Please Help! Post 53975 by laila63 on Thursday 29th of July 2004 01:44:19 PM
Old 07-29-2004
Question Please Help!

I'm trying to comple this small program to waste CPU usage. The code is as follow:
Code:
#include <time.h>

#define SLEEPTIME 5

time_t start, end;
start=time(NULL);
end=start+SLEEPTIME;

while(end > start){
     start=time(NULL);
}

and i got the following errors:

Code:
 g++ waste.cpp
waste.cpp:6: error: ISO C++ forbids declaration of `start' with no type
waste.cpp:6: error: conflicting types for `int start'
waste.cpp:5: error: previous declaration as `time_t start'
waste.cpp:7: error: ISO C++ forbids declaration of `end' with no type
waste.cpp:7: error: conflicting types for `int end'
waste.cpp:5: error: previous declaration as `time_t end'
waste.cpp:9: error: syntax error before `while'

what could be wrong? if there's a better way to do this, please suggest.
Thank you much!
 
CPP(1)							      General Commands Manual							    CPP(1)

NAME
cpp - C language preprocessor SYNOPSIS
cpp [ option ... ] [ ifile [ ofile ] ] DESCRIPTION
Cpp interprets ANSI C preprocessor directives and does macro substitution. The input ifile and output ofile default to standard input and standard output respectively. The options are: -Dname -Dname=def -Idir Same as in 2c(1). -M Generate no output except a list of include files in a form suitable for specifying dependencies to mk(1). Use twice to list files in angle brackets. -N Turn off default include directories. All must be specified with -I. Without this option, /$objtype/include and /sys/include are used as the last two searched directories for include directives, where $objtype is read from the environment. -V Print extra debugging information. -+ Understand C++ comments. The output file contains processed text sprinkled with lines that show the original input line numbering: #line linenumber "ifile" The input language is as described in the ANSI C standard. The C compilers do not use cpp; they contain their own simple but adequate pre- processor, so cpp is usually superfluous. FILES
/sys/include directory for machine-independent include files /$objtype/include directory for machine-dependent include files SOURCE
/sys/src/cmd/cpp SEE ALSO
2c(1) CPP(1)
All times are GMT -4. The time now is 09:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy