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..plea se bear with me
Thanks
Aejaz
# include<iostrea m.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<<set w(10)<<Sum[x][m]<<endl;
}
}
getch();
}
}
my output reads
11 25000
11 25000
12 35000
12 35000
so on..so forth 2 10405
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
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..plea se 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<iostrea m.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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 code.
The file upload system is working fine if the file is smaller than the
defined size, but if it's larger, then both the _POST and _FILES arrays
are completely empty:
|
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 exception
handling mechanism which will allow me to pass character information
about an error and its location from lower-level classes.
Can you please critique the following exception handling mechanism in
terms of my requirements ?
|
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 completely/succsessfully on the
client's computer before updating some metadata on the server (file
downloaded date for instance)
However,
All examples i have tried, and all examples I have found that other people
says works - doesn't work for me :-(
|
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
|
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 handling, exception handling and string processing.
A text file contain English sentences and the only punctuations used are
" quote
| |
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 gets about
3 or so. It also gets very awkward in nested loops, where you want to
check for normal loop processing in the loop condition, not errors.
Yes, you could put some generic exit flag in the loop condition, but
when you're simply done if...
|
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 character arrays)
and extracting it fom the file. Might be possible there is a peoblem in my approach
I am designing it with the help of OOP i.eclasses
untill now i have made a structure inside the class.
plz suggest me the way to implement them...
|
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, sell price, and
a taxable flag (a Y/N char) and then write this all out to a file
(preferably just a plain old text file) and then read it in later so
that I can keep a running inventory. The problem that I am running
into is when I write to the...
|
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 np # for array/matrix processing
import matplotlib.pyplot as plt # for general plotting
from mpl_toolkits.mplot3d import axes3d # for 3d plotting
wordList=
numFiles = 0
numDataSets = numVectors = sizeVector = 0
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |