I am new to c++ programming i just want to know how to write the data into different files.Suppose my input files has 1-8 ids so each id data must be stored into each different file. And below is my code.
In my program I open two files and write data into each, and close them. this is done in a while loop.
int main() { while() { myFile = fopen("file1.txt","w"); myFile2 = fopen("file2.txt","w"); // write data into files using fprintf() in a for loop fclose(myFile); fclose(myFile2); } }
However, after some iterations the fopen() for myFile2 fails.
Debug assertion failed! Program.... File ......srcfprintf.c Line 55
Expression (str != NULL)
I have not been ableto locate the bug in the code that is causing the failure.
I am writing a program to hide files behind other files using Alternate Data Streams in Windows NTFS file systems.
The program is as follows:
Code:
#include <stdio.h> #include <stdlib.h> int main(void){ char hostfile[75], hiddenfile[75], hiddenFileName[15] ; printf("Enter the name(with extension) and path of the file whose behind you want to hide another file: "); scanf("%75s", hostfile);
[Code]...
The complier is showing error as "Extra Perimeter in call to system" but I am not getting where?
I just want to know how fast can C++ generate data? For example, I have a downstream device that is connected to my pc via a Gigabit Ethernet, and I have to generate some pattern and send it over the Gigabit interface.
I was curious if there is a way that I can see how fast I can generate data? I was curious if I can exercise a good portion of the bandwidth ! for example, sending about 600 Mbits/sec.
How do I find out, first, whether I can do this with C/C++, and, second, how do I know how fast I am sending data?
-Create three files namely all_numbers, odd_number and even_number. -Get the number of records and the numbers to store from the user. -Save all the numbers in "all_numbers" file. -Read each number and check whether it is odd or even. -Store the odd numbers in odd_number file and even numbers in even_number file. -Finally, print the numbers stored in odd_number and even_number files.
I have written the following code to add data to text files which are required to store 3D scan data (I have to calculate the y-coordinate). My code seems to work except that it stops working when I want to create more than ten text files i.e. the directory I am trying to store them in will not hold any more than ten text files. Code is shown below.
Given an array of angles A = [0 30 60 90 120 150 180 210 240 270 300 330 360]
Write a program that will generate the data set of angles automatically and provide three columns; sin(angle), cos(angle), tan(angle). Make this program as compact and readable as possible.
When you have constant arrays, they are stored in the programme memory space. Upon execution, they are copied into the data space for easy access. To save space in the data space, it is possible to stop it from being copied. Some compilers will deal with this by just specifying the array as const, g++ has a type modifier called PROGMEM.
In any case, the problem is that I'd like to generate some data, preferably without using an external programme to do it. Hence, my question using the template system. Now I could possibly use macro metaprogramming via boost instead of template metaprogramming, and I may have to go that route. However there are limitations, especially since its numbering system is only equivalent to an unsigned byte, which I possibly could use, but could become more messy than if I use the template system that has long long types as well as a whole slue of type safety mechanisms.
need to create a program for the following problem
1.Program takes messages as input at a rate “X” msg/sec, and outputs those messages at “Y” mgs/sec in a file.
2.The peak value of X can be 10msg/sec, and Y can be at max 5msg/sec. System should be designed in such a way that it can handle the peak input rate of 10msg/sec for not beyond 5 minutes.
3.Message contains following fields – unit id, timestamp, temperature.
4.Input data to be read from a file. Output data to be written to a file.
5.For testing design 3 types of profiles –
a.Profile 1 for 10 min – low rate, i.e. X = 4 msg/sec on an average throughout the period. b.Profile 2 for 10 min – Max rate, i.e. X = 10 msg/sec for 2 min; then a sleep of 2 min, then repeat the same pattern till complete period c.Profile 3 for 10 min - Max rate, i.e. X = 10 msg/sec for 5 min; then no traffic for next 5 min
I am trying to make a simple program, I would like it to be able to do the following, Write a program that opens two text files (input1.txt and input2.txt) for input .The program should write the followings in the two files. input1.txt:
This is the first line in input1.txt. This is the second line in input1.txt. This is the third line in input1.txt. This is the fourth line in input1.txt.
input2.txt:
This is the first line in input2.txt. This is the second line in input2.txt. This is the third line in input2.txt.
What would be the best way to go about doing this? I wrote the program below, but I don't think that it works.
#include <iostream> #include <fstream> #include <string> int main() { using namespace std; string input1;
I need to write a program that merges the numbers in two files and writes the results to a third file. The program reads input from two different files and writes the output to a third file. Each input file contains a list of integers in ascending order. After the program is executed, the output file contains the numbers from the two input files in one longer list, also in ascending order. Your program should define a function with three arguments: one for each of the two input file streams and one for the output file stream. The input files should be named numbers1.txt and numbers2.txt, and the output file should be named output.txt.
Okay, so my assignment for my C class is to generate a program that will allow the user to enter data for a stock and calculate the amount of stocks that ended up being positive, negative, and neutral.I tried to do this using one stock, here is my code;
My program needs to receive data continuously from one process and the received data is read continuously by another process.But when I am trying to create a pipe using mknod on fat32 file system in linux , it throws an error saying "mknod: operation not permitted".
Write a program that reads data from a file (use the attached data file). These data are a student name and 3 test scores. The program should calculate the average of the 3 test scores, and display the name, 3 test scores, and the average to the monitor.
Useful tips: a) Include the following header files: iostream, fstream, iomanip, and string b) The name of the data file is “datafile.txt”, you need to save the file in the same folder of the source file. c) use the manipulators (setw, setprecision, setfill, showpoint, fixed) to format the average with 1 digits after decimal point as following. d) Use character ‘ ’ for tab.
I can access a physical device to read a specific sector in a USB hard drive. But my question is how can I Write to a specific sector? Lets say I want to replace what is in a specific sector of a hard drive with a new data.
The problem is I have a function which sets some variables and I want to access the variables, but myfunc() is nested too deeply for me to pass a data structure all the way down and to return all the way up. The functions reside in different files. I'm not allowed to use extern structs (i.e. a global variable).
How to use a class and instantiate it in myfunc(). My solutions are:
- using the singleton class method - static variables and function residing in the class (but I'm suspicious of this way. seems like it's just class variables masquerading as global variables.
I'm trying to compare two data files character by character to see if they are the same. If the files are different, the program should print out the line numbers of where they do not match. So far, I have the part where it returns 'T' for when the files are the same and 'F' when they are not. But how should I start where the program prints out the line number where the characters are different? I am thinking of an array but nor sure how to start it.
The Problem You are part of a company writing a spreadsheet program. As you know, spreadsheets can be sorted on any column. You're part of the project is to write one binary tree function to sort the data [Hint: use different fields when inserting nodes in the tree.] and a second function to list it in either an ascending or descending sequence. [Note: Each of these functions may actually need to be a set of related functions.]
For sample data you will have a disk file containing information about Shakespeare's plays. Your first function should create a tree based on the sort selected by the user and the second function to display the data in the sequence selected by the user. Regardless of the column being sorted, data in individual records always be displayed in the same line of the output.
Input : Each record will contain the following information: First Performed 9 characters Printed 5 characters Title 26 characters Type 7 characters
Output : Tabular output should be aligned in columns with two spaces between each. All columns should have headings. It should be sorted on the column specified by the user.
Example (This sample data provided so you can test your program.) If the data is:
1595-96 1600 A Midsummer Night's Dream Comedy 1594-95 1623 Two Gentlemen of Verona Comedy 1596-97 1623 King John History 1597-98 1598 Henry IV, Part 1 History 1611-12 1623 The Tempest Comedy 1602-03 1623 All's Well That Ends Well Comedy
[Code]...
Source: [URL]...
Possible outputs are
1 - for a sort by title: First Performed Printed Title Type --------- ------- -------------------------- ------- 1595-96 1600 A Midsummer Night's Dream Comedy 1602-03 1623 All's Well That Ends Well Comedy 1606-07 1623 Antony and Cleopatra Tragedy 1599-1600 1623 As You Like It Comedy
[Code]....
2 - for a sort by first performed: First Performed Printed Title Type --------- ------- -------------------------- ------- 1590-91 1594? Henry VI, Part 2 History 1590-91 1594? Henry VI, Part 3 History 1591-92 1623 Henry VI, Part 1 History 1592-93 1623 Comedy of Errors Comedy 1592-93 1597 Richard III History
I was wondering if i had to say simply retrieve data from a server whether it be simple plain text for variables or download whole files (FTP), what would be the best method for this? I would imagine there is a pretty big difference between retrieving text and downloading files but im just wondering what the best thing would be to research for both.