C/C++ :: Program To Print Alternate Records From A File
Aug 23, 2013Code for the following.
How to print alternate records from a file using fseek?
Code for the following.
How to print alternate records from a file using fseek?
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've implemented a records system for a college assignment and everything works as intended. However upon increasing the amount of records to store in my array above 10, the program crashes upon adding a new employee and I can't work out why...
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#define esize 10 /* Change max-records */
[Code] .....
Is this the right codes for deleting a recoed on the text file.
void dlte(){
string line, recorddate;
cout << "Please Enter the date of record you want to delete: ";
cin >> recorddate;
ifstream myfile;
ofstream temp;
myfile.open("herald.txt");
[Code] .....
I have to ask the user if they want to delete any records. The user can enter -1 to finish deleting records. I have to write the remaining records in an output file. So, i have this, but
1) it doesn't let me enter more than 1 id, and
2) it doesn't output anything to my output.txt.
records.txt
6
123 Jose Garcia 99
345 Luis Garcia 87
234 Jazlyn Soriano 79
456 Carter Sander 95
567 Natalia Soto 67
789 Isabel Santana 80
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
class Student {
private:
int id;
[Code] ....
I've got a program to read the input file as records. The problem is all it does is cout Record Number etc but it doesn't grab the data.
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
int main() {
const int RANGE = 12;
string tab[RANGE];
[Code] .....
I have to ask the user if they want to delete any records. The user can enter -1 to finish deleting records. I have to write the remaining records in an output file. I have this, but 1) it doesn't let me enter more than 1 id, and 2 it doesnt output anything to my output.txt.
records.txt
6
123 Jose Garcia 99
345 Luis Garcia 87
234 Jazlyn Soriano 79
456 Carter Sander 95
567 Natalia Soto 67
789 Isabel Santana 80
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
class Student {
private:
int id;
string firstName;
[Code] .....
My size of binary file is 1920 KB and my struct size is 124 kb. now to find number of records in file I divided 1920/124 and it gives me 15.4.... do I add 1 to 15.4 and make it 16 or do i take it as 15?
View 9 Replies View RelatedThe following shows a sample input file for class called Training. How can I read these uneven records in to class?
1/12/2013
8:00 – 17:00
250.00
2
871012-10-5543 //---->>Participant ID and namess in training T2100
Tony
Stark
700607-10-6231
[Code] ....
An array of Training (based on the number read from the file) should be created dynamically then load all the details into each Training object.
i have this program that i am undertaking.....this project needs to store customer details, edit them and delete them...now i am facing the problem of deriving a code to edit those details...
MY CODE
HTML Code:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main () {
int choice [1];
string name;
[code].....
I was trying to make a tic tac toe game where the user can play against the computer
It s in borland c++ and not in c++ 11 so i wanted to convert it into c++11. My program shows error since there is nothing called conio.h in c++11. Hence I want to know if there is any alternate keyword gor the function getch() so that i could ask the user to press [ENTER].
Code:
#include<process.h>
#include<stdlib.h>
#include<string.h>
#include<iostream.h>
#include<conio.h>
int usbox,i,j,nandu=0,result,cusb,cobox,r,d;
int playl=0;
char copybox[10];
[Code] ....
How do reverse every alternate words in a string that I read into my program:
e.g. The mouse was caught in a clothes peg.
reversed (including the full stop)
The esoum was thguac in a clothes gep.
I could program it to reverse the whole sentence. But no clue how to reverse certain words such as every even word. Do I need a function and/or loop to solve this?
#include<iostream> // allow input and output
#include<string> // allow for larger entries of characters
using namespace std;
int main() {
string sentence, reversed_sentence;
[Code] ....
I wrote this program to scan a number and a string until EOF then print them to a file named "data.list". the problem is that the program duplicates last line of input in the output file. so for example if the input is :
1 test
2 dream
3 code
then output (in data.list file) would be:
1 test
2 dream
3 code
3 code
I also changed the program code so that it reads from data.list file. even here it duplicates last line!
so when program reads the info above saved in data.list it would be:
1 test
2 dream
3 code
3 code
3 code
here's the code for writing:
#include <stdio.h>
int main( void )
{
int num;
char str[80];
FILE *fPTR;
fPTR = fopen( "data.list", "w" ); // opens a file named "data.list", create if doesn't exist
while(!feof(stdin)) // loop until End-Of-File is pressed. Ctrl-Z in Windows, Ctrl-D in Unix, Linux, Mac OS X
[Code]...
and the one for reading from file:
#include <stdio.h>
#include <conio.h>
int main( void )
{
int num;
char str[80];
FILE *fPTR;
[Code]...
How do I fix this behavior??
I'm trying to write a C program that will take a file that is delimited by colons and separate it out in to 5 sections:
0002:0003:0002:0080:<HTML>
0002:0004:0002:0080:<BODY>
I have the struct code in place but not sure how to actually store each of the 5 parts in memory. Here is the code below:
Code:
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)
struct contents
{
int source,destination,type,port;
char data[50];
};
[Code]....
The program will prompt the user to enter a every student's first and last name, major ( of 4 choices CMPS MATH PHYSICS or EECE ), and grade. it's agreed that the professor will enter the name NoMore to stop the entry.
the program willl then store the info in a txt file. after closing the input file, the program will open it again read the records one at a time until end of file, and do some statistics including: highest grade, average grade, and highest average by major.
Finally the program will print the results....
I have faced a strange problem in File Save Routine. I have written a module to save data to binary file . I have designed a structure and put information in that and save it to file . I save multiple such records one after other. I use fwrite , fflush instructions.
The module is working fine. I have saved near about 35 such files. But in one file , the module has saved Blank Records. The file size if perfect but the file is totally blank. It has happened for only one file but need to know the reason.
Objective of this program is to read binary data from a file and print it.
Code:
#include <stdio.h>
void readFile(void);
int main(){
readFile();
return 0;
[Code] .....
But When I Run This Code First It Print "Error." Then Rest Of The File.Say In My File I Have "I AM HUMAN", It Prints "Error. HUMAN"!!
I Cant Figure Out Whats Wrong In The readFile() Function.It seems right to me.
Code:
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
char buffer[256];
FILE * myfile;
myfile = fopen("read.txt","r");
[Code]...
I also got an error in printing wherein the data in read.txt is "Hello" newline "World" and my program prints world twice.
I have the records "File attached"
My query is
from c in JOB_HISTORies join d in DEPARTMENTs on c.DEPARTMENT_ID equals d.DEPARTMENT_ID select new {d.DEPARTMENT_NAME,c.START_DATE,c.END_DATE}
How do i put the record Accounting in the same row to avoid duplication.
I can't get my program to print only AVAILABLE SEATS; instead it prints Both Available and Taken.
//Program allows you to delete and add seats to the Airplane. Also to upload seat settings as a text file.
#include <iostream>
#include <fstream> //file stream for text file
#include <string>
using namespace std;
[code].....
I need help writing a program where I use small letter to write names in Big letters. (I dont know if you understand what i mean). Follow link to description.
[URL]
I am writing a program that prints the sum of even and odd numbers and here is my code
#include <iostream>
using namespace std;
const int SENTINEL = -999;
int main() {
int integers = 0;
int even = 0;
int odd = 0;
[Code] ....
Nut now in the output it adds -999 to the odd numbers ....
Is there a way to indicate how many records exist in a given file? For example, vectors have the vector.size() command to show the number of given elements. Is there a such command for files and records?
View 6 Replies View RelatedWell what the title says, but I can't get it done. This is what I got
Code:
#include <stdio.h>#include <string.h>
int main(void)
{
char word;
int count;
printf("Enter a word.
[Code] ....
I have to develop script in C to print the alphabets in given notation.
Please check the attachment.
i have to make two functions one recursion that ask the user to enter number of rows and i use recursion to tell him how many pins there are ex. user enters 5 there are 15 pins. I did this function now i need a function that prints an asterisk triangle for my recursion function so for 15 it should look like this
*
* *
* * *
* * * *
* * * * *
i tried many times but can't make it descend like that i can only get like a right triangle..the hard part is that it goes with the users number so if they enter 3 for example it should be 3 rows.
int pins(int n){
if(n==0){
return 0;
[code]....