473,320 Members | 1,713 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,320 software developers and data experts.

File Handling in C++ ...Arrays

Hey all

I am new to VC++

I want 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

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
Jul 19 '05 #1
2 10390
WW
aejaz wrote:
Hey all

I am new to VC++

I want 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

[SNIPped unformatted code]

Why don't you write it into a file? <OT>Or redirect your output to a file
with the > symbol?</OT>

--
WW aka Attila
Jul 19 '05 #2
aejaz wrote:
Hey all

I am new to VC++
Here we discuss the C++ language, not VC++ (which is an implementation
of the C++ language - sort of).

I want 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
C++ doesn't have "copy pasting" capabilities. Sounds like an OS issue to me.

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

Thanks
Aejaz
I don't see a C++ question here, but I'll comment on some of the
problems with your code.

# include<iostream.h>
# include<conio.h>
# include<math.h>
# include<iomanip.h>
Of these, only <math.h> is standard (and it's deprecated). <conio.h> has
never existed in C++. The others existed in old, pre-standard C++. Use
<iostream>, <cmath>, and <iomanip> instead.

Also, you'll probably need to add this:

using namespace std;

void main()
main must return int. void is not and never has been an acceptable
return type for main.
{
void clrscr();
Local declaration of a function. That's unusual. Also, I suspect this is
not a function you are writing, in which case you should only declare it
by #including the appropriate header.
int i,r,j,m,x;
static Sum[5000][5000];
There's no type for Sum. This is illegal. Even if it were 'char' this
would be an extremely large array. You may have to check your compiler's
documentation to see if
Sum[1][1]=25000;
Sum[2][1]=35000;
You are aware, aren't you, that C++ arrays use 0-based indexing? Are you
sure you didn't want

Sum[0][0] = 25000;
Sum[1][0] = 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;
}


This formating makes to code nearly impossible to understand.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ian.H | last post by:
Hi all, Uploading of files.. AFAIU from the manual, if a file is larger than the size defined in the form or larger than upload_max_filesize in php.ini, that _FILES should hold an INT error...
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
6
by: SandyMan | last post by:
Hi, I am able to open a binary file for reading but can someone tell me as how to go about converting a Binary file to ASCII file using C. Thanks In Advance SandyMan
0
by: RDX | last post by:
Hi Everybody, well this is the first time I am going to enter a forum and I hope I will be able to get advices from you friends. My problem is as follows I have to use arrays,class,file...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
2
by: coolprateek2007 | last post by:
Here will designing the code for the library management software i am facing the problem while handling the data of the variables I am not able to insert the data into the file(specifically of the...
19
by: rmr531 | last post by:
First of all I am very new to c++ so please bear with me. I am trying to create a program that keeps an inventory of items. I am trying to use a struct to store a product name, purchase price,...
1
by: csgirlie | last post by:
I'm trying to store or arrange three sets of two-dimensional data into three 2xN matrices that are stored as NumPy arrays. import os # for file handling functions import numpy as...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.