----- Original Message ----- From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] ; NetBehaviour for networked distributed Sent: Monday, February 05, 2007 12:00 PM
Subject: Re: [NetBehaviour] DIWO: Top 10!


* clear the screen.
* open the file top10.dat for writing as stream number one.
* loop with the integer variable i starting at one and finish the loop
after i has reached ten.
* set the variable playername to be a string containing the word Player
with the numerical value of i converted to a string appended to it.
* set the variable playerscore to be an integer value which shall be
derived from the value of i multiplied by one hundred with the result
subtracted from one thousand.
* write variables both, playername and playerscore, in that order, to the
output stream.
* increment the value of the variable i by one, and if this value is ten
or less, begin the loop again.
* close the output stream numbered one, thus end writing to the file
top10.dat.
* display a nefarious message to the user.
* end the program

include <iostream>
using namespace std;
int main()
{
// can't specifically be bothered to recall how to write files in C++
char player_names[10];
int player_scores[10];
for(int i=0;i<10;i++){
player_name[i]=new char[8];
strncpy(player_name,"Player",6);// assuming dest,src,noofbytes -- check
player_name[i][6]='0'+i; // again might need to check RHS syntax here
player_name[i][7]=0;//terminate string
player_score[i]=1000 - (i * 100);
cout << "\n" << player_name[i] << "\t" << player_score[i];
}
cout << "\nThis useless piece of crap program is about to exit,
returning a value of -1 just for the heck of it.";
return -1;
}

On 5/2/2007, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

CLS
OPEN "top10.dat" FOR OUTPUT AS #1
FOR i% = 1 TO 10
 playername$ = "Player" + STR$(i%)
 playerscore% = 1000 - (i% * 100)
 WRITE #1, playername$, playerscore%
NEXT i%
CLOSE #1
PRINT "Data written to file"
END
_______________________________________________
NetBehaviour mailing list
[email protected]
http://www.netbehaviour.org/mailman/listinfo/netbehaviour
_______________________________________________
NetBehaviour mailing list
[email protected]
http://www.netbehaviour.org/mailman/listinfo/netbehaviour

Reply via email to