Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File Handling in C++ ...Arrays

1 view
Skip to first unread message

aejaz

unread,
Sep 23, 2003, 5:19:03 AM9/23/03
to
Hey group

I am new to VC++

Wish to have my c++ program output to a notepad file

i store my data in arrays and then use cout to output the data in
DOS...as i generate data in the order of 1000's ...i am having a
problem with physically copy pasting the data into notepad

{I think he wants to output to a text file which puts it on topic.
-mod/fwg}

Here is my code...please suggest what changes are necessary
My coding is not really that efficient..please bear with me

Thanks
Aejaz

# include<iostream.h>
# include<conio.h>
# include<math.h>
# include<iomanip.h>

void main()
{
void clrscr();
int i,r,j,m,x;
static Sum[5000][5000];
Sum[1][1]=25000;
Sum[2][1]=35000;

for (j=2;j<=11;j++) // input the data into arrays
for (i=1;i<=pow(2,j);i++)
{
if(i==1)
{
Sum[i][j] = Sum[i][j-1] + 25000;
Sum[i+1][j] = Sum[i][j-1] + 35000;
}
if(i>1)
{
Sum[i][j] = Sum[r][j-1] + 25000;
r=r+1;
Sum[i+1][j] = Sum[(i+1)/2][j-1] + 35000;
}
i=i+1;
r=2;
}

for (m=2;m<=11;m++) // output the data
{
for (x=1;x<=pow(2,m);x++)
{
for(i=1;i<=2;i++)
{
cout<<x<<m<<setw(10)<<Sum[x][m]<<endl;
}
}
getch();
}

}


my output reads

11 25000
11 25000
12 35000
12 35000

so on..so forth

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Dirk Feytons

unread,
Sep 23, 2003, 2:04:32 PM9/23/03
to
aejaz wrote:
> Hey group
>
> I am new to VC++
>
> Wish to have my c++ program output to a notepad file

Were the answers you received in c.l.c++ not adequate enough?
I see nothing of the suggested corrections in this code.

--
Dirk

(PGP keyID: 0x448BC5DD - http://www.gnupg.org - http://www.pgp.com)

.oO° I wanna do centuries in a lifetime... °Oo.

Sylvain

unread,
Sep 24, 2003, 7:27:25 AM9/24/03
to
Hi,

If what you want is just to copy the result into a notepad file (.txt
file). What you can do is to invoke the compiled program from a cmd
window (Start menu/ Run.../ key in cmd).
then My_program.exe > my_text_file.txt

Afterward you can read the content of my_text_file.txt by opening it
with notepad

Regards

Sylvain


aejaz wrote:

> Hey group
>
> I am new to VC++
>
> Wish to have my c++ program output to a notepad file
>
> i store my data in arrays and then use cout to output the data in
> DOS...as i generate data in the order of 1000's ...i am having a
> problem with physically copy pasting the data into notepad
>

{Excessive quote -- of entire article -- snipped. -mod/fwg}

Francis Glassborow

unread,
Sep 24, 2003, 4:18:37 PM9/24/03
to
In article <10643114...@seven.kulnet.kuleuven.ac.be>, Dirk Feytons
<Dirk.F...@norubbishplease.easynet.be> writes

>aejaz wrote:
>> Hey group
>>
>> I am new to VC++
>>
>> Wish to have my c++ program output to a notepad file
>
>Were the answers you received in c.l.c++ not adequate enough?
>I see nothing of the suggested corrections in this code.

It is possible to post to both clc++ and here at the same time, get a
bundle of answers on clc++ before your post here passes through
moderation.

His post was sent to me for acceptance at about 11.30am (UK time) on
Monday. It did not arrive in my moderation queue till after three this
morning by which time I had gone to bed and so it was not handled till
about 10.30 uk time today (23/09)

Why the long delay? Well some time the middle of last week a new worm
attack was launched on the Internet. For some reason I became a major
target and have until early today (when my ISP managed to install some
filtering) been receiving over 2500 emails a day (about 25 times my
normal) rejection still requires that my system sees the headers.

The point is that such an increase was not to me alone (though I think I
was far above the average) and many ISP's mail servers were staggering
under the load.

Now I hope whichever of my fellow moderators gets this post will accept
it because I think the OP deserves a public response to the public
criticism he has received above (I just checked the headers on his post
and there was about a forty hour delay between his submission and it
being accepted and distributed). Please note that such a delay is very
unusual and is certainly in no way his fault.

{ Agreement and some facts.
Average moderation (post to accept) delay is under 12 hours but there
are articles every month which take over 24 hours. It is possible to
check original date in the headers of posts to this group. -mod/jep }


--
Francis Glassborow ACCU
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation

Attila Feher

unread,
Sep 25, 2003, 9:50:44 AM9/25/03
to
Francis Glassborow wrote:
[SNIP]

> Why the long delay? Well some time the middle of last week a new worm
> attack was launched on the Internet. For some reason I became a major
> target and have until early today (when my ISP managed to install some
> filtering) been receiving over 2500 emails a day (about 25 times my
> normal) rejection still requires that my system sees the headers.

I can confirm that. I receive approx 5000 mails on peek days. On one
account, it is more on the two together. And according to a mail (what also
Daveed has possibly received) not only we do get the emails with the viruses
(we, you ask, yes we, posterds of comp.lang.c++.moderated) but we appear to
send it.

I have received a mail yesterday complaining why do I send viruses. The
mail was also sent to many others. Those many others were (I guess) *all*
posters of comp.lang.c++.moderated! Daveed I remember, an Ericsson address
(other than mone) called usenet_clcppm or something like that etc.

The virus sends the mails using randomly selected email addresses from
mailbox and newsgroup files of Outlook Express. This makes me think that
someone currently reading this newsgroup has the virus on his Windows PC.
So pretty please everyone (unless you have an up to date virus software
running) go to
http://www.symantec.com/avcenter and click the blue picture on the right
side with the globe and the text check for security risks and follow the
instructions to virus scan your PC. Also those who have any running virus
checker: check if it updates itself, some viruses start by killing the
update process. Also please install the patches which closes the I-Frame
exploit what the virus builds on. If you are already there (Windows update
center) please install all critical updates.

At least one of you readers have a computer sending out viruses in our name.
Please everyone clean the machines to make sure it is not you.

I hope mods will let this post go through.

{Yes, but please let us not pursue this further. Note that not having a
good virus checker on a computer connected to the Internet is profoundly
anti-social and not just a matter of putting up with virus infections
yourself but seriously damaging to the entire Internet community. -mod}

--
Attila aka WW

0 new messages