C/C++ :: File Handling And Conversion Of Data

Jan 10, 2014

I am having a 1file (given file) and in that i have some binary information and i niw i want to convert those binary information into decimal form and save it into new file (output fle). I was written a code but that was not working properly.

Code :
main() {
int i,j,n,ch;
int a[100][100];
FILE *p,*q;
char file1[20],file2[20];  
printf("enter the given file name");

[Code] ....

View 2 Replies


ADVERTISEMENT

C++ :: File Handling - Data Overwritten

May 16, 2013

Every time I write in file using ofstream it works fine except for one thing that when the file is re-opened after writing something and we try to add more data then previously added data is removed how to get rid of this.

<code>

struct abc {
char name[100];
int a;
};
int main() {
ofstream file;
file.open("text.dat", ios:ut | ios::binary);

[Code] ....

View 1 Replies View Related

C++ :: Data File Handling Error - Character Strings Not Copied On Text File

Nov 24, 2013

I have this code for a computer project... (store management) but the character strings are not copied on text file..

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
class Store {
public:
char *item_name[5];
store()

[Code] .....

Now when i run the program, it gives a error :::
ERROR
address 0x0

How can i write these strings to the text file?

View 2 Replies View Related

C/C++ :: Quiz Program Based On Data File Handling

Dec 22, 2014

I'm trying to make a Quiz program based on C++'s Data File Handling capablities. I've attached the code in .txt file and I wonder why I'm getting the error identifier bScience cannot have a type qualifier?

Attached Files QuizPro.txt (9.6 KB)

View 7 Replies View Related

C++ :: Handling Data Types As Inputs

Apr 10, 2013

I'm fairly new to C++ programming. I wanted to accept a datatype as an input. I've seen something similar while working with the <queue> library.

When defining a new object of queue

For example:

queue<int> Queue;

How is <int> handled ??

View 1 Replies View Related

C :: Data Handling And Structure For Embedded UAV Project

Apr 16, 2014

Data handling for a UAV project I am trying. My background is in Microcontrollers but I have never had exposure to "sound" programming practice...

I have got 2 microcontrollers to drive a UAV craft I've made. One "firmware" micro collects all the sensor data and then passes it to the other "application" micro for control processing. Once decisions have been made this is sent back to the "firmware" micro so that actions are taken.

So in essence I am sharing a raw data chunk periodically between the 2 processors that has outputs and feedback data. For the moment this is captured as one big buffer array on either micro after receiving. For easier structure I thought of bouncing this buffer that contains all sensor information and control variables between the 2 processors (visualize a ping pong game with all the possible variables from both micros - bandwidth between the micros is not a limitation) There are quite a few modules that want to access information from this buffer and write control actions back to it.

I was thinking of constructing a struct on both micros to access this "raw data" from the buffer and set it up with variable names so that it is easier for functions to read info and write controls back.

But this would mean that the data is accessible to every function, and there is the fear that some functions will write to the input data or write to control variables that they should not have access to. I also need to reduce memory copies and the like due to limited memory on each micro.

View 4 Replies View Related

C++ :: Multiple Data Streams In One Class - Handling All In One Member

Jan 24, 2014

I have to implemente the to_string method. Whats the fastest way? Stringstreams. But I have to use C++ without any headers, so I need to implement the stringstream class. How can an stringstream hold one float? An double? Hoq cqn I implement an strigstream myself?

View 8 Replies View Related

C/C++ :: Pass Path In File Handling To Create Or Open A File?

Jul 14, 2012

I have a folder "pics" in g: drive. There I want to create some text.txt file. Thus, the final path is "g:pics ext.txt".

How can I do that?

View 3 Replies View Related

C++ :: File Handling - Program To Read Inputs In TXT File

Mar 26, 2013

I've written a program to read inputs in a text file. The file named Input.txt contain integers 2 3 and 4. My program is as follows:

#include<iostream>
#include<cstdlib>
#include<fstream>
using namespace std;
int main (){
int x,y,z;

[Code] ....

the program is outputing x=2293616 , y=0 and z=0 instead of x=2, y=3 and z=4.

View 9 Replies View Related

C :: File Handling And BST

Mar 27, 2014

I need to insert my thesaurus words .txt to my c program applying BST. But I am not sure how.

Here are my file: awwwwwwww.txtthes.c

View 1 Replies View Related

C :: File Handling Sorting

Mar 6, 2015

I am accepting the word from user and arranging it in ascending order like in dictionary in a file . I am doing this by comparing the user entered word from existing word in the file . All the word which is smaller then user entered word is copied to another file "temp.txt" , then the user word is printed and then the remaining word ( which are larger) from "abc.txt" to "temp.txt" . But program close as soon as i enter the second word

Code:
#include<stdio.h>
#include<string.h>
main() {
FILE *fp,*ft ;
fp = fopen("abc.txt","r+");
ft = fopen("temp.txt","r+");

[Code]....

Both file are already created before /

View 2 Replies View Related

C :: WAV File Handling And Filtering

Dec 29, 2013

I got this issue to tackle which consists of using an FIR LPF filter to filter a wav file using C programming.

Till now I managed to tackle the filter part following this link: Implementation of FIR Filtering in C (Part 1) | Shawn's DSP Tutorials (I have my own filter co-efficients which have been produced using FDAtool on MATLAB and some other minor changes have been applied to match my requirements)

Now, the link shown does not compensate for files having a header. I have three wav files which need to be filtered. Thus I need to first extract the data from the header .. this was done using RIFFpad. Now that I have the data

Info from RIFFpad:
fmt -
Offset=20
ID=fmt

[Code].....

I've got this hint to start with: Each audio datasample inside the wav_files can be made up of a number of bytes and these bytes arestored in the little-endian order. Inside your program you have to change this to a big-endian order.

View 8 Replies View Related

C :: Using File Handling With Tree

Apr 8, 2014

I'm given a project in college to use trees(AVL tree, to be specific) and file handling(not very conversant with it). But I'm not able to relate the two.

I only know that files can be used to store data. But in what way can trees and file handling be connected? I know how to implement trees but how to store it as such in files?

View 1 Replies View Related

C++ :: File Handling Vs Shared Memory?

May 27, 2014

In interprocess communication(IPC) when processe have to share data among each other,why cant they all connect to one single file and share data with basic file handling functions such as read and write?

Why do we need

shared memory(shmget shmat(),shmdt()..etc)
and
mapped memory(mmap(),munmap()..etc)

concepts?

View 3 Replies View Related

C++ :: File Handling Inside A While Loop?

Aug 5, 2013

I have two files like original.txt and replace.txt which has equal nbr of lines in both of them.

I need to loop through these two files line by line and replace the line in original.txt to the line in replace.txt

eg :

output.txt :

1|raj|65.4|Y|
1|ramesh|65.4|Y|

replace.txt :

1|raj|65.4|Y|
Cannot be processed|1|ramesh|65.4|Y|

What I need here is when reading of output.txt reaches second line of file "1|ramesh|65.4|Y|", it has to be replaced with the second line in replace.txt "Cannot be processed|1|ramesh|65.4|Y|".

1|ramesh|65.4|Y| --> Cannot be processed|1|ramesh|65.4|Y|

After the end of loop the contents of two files should be like :

original.txt :

1|raj|65.4|Y|
Cannot be processed|1|ramesh|65.4|Y|

replace.txt :

1|raj|65.4|Y|
Cannot be processed|1|ramesh|65.4|Y|

The files can have variable number of lines but both will have same number of lines each.

View 1 Replies View Related

C/C++ :: Specification Of Path In File Handling?

Jul 12, 2012

i want to create/open any file present in any location in my computer. How do I assign a path in C++ syntax?

View 1 Replies View Related

C :: Student Record System / File Handling

Feb 25, 2013

Code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
}

[code]....

I dont know how to modify the previous record that i have done in the Add Student function. i searched from different sites and got this code for modifying a record in a text file. But, i cant figure it out why its not working.

View 2 Replies View Related

C/C++ :: Error Handling For File Opening And Reading

Apr 23, 2014

I am writing to write a program and performs the following tasks

- Reading a file (txt file contains some temperature values)
- Display the temperature values (contents of the file)
- Calculating the average of the temperature values in the file.
- finds the maximum and minim value of temperature in the file.

The program is user interactive and waits for the user input and process according to his input (choice)

I have managed to complete the program and covered all the expect except the error handling for file opening and reading, although I have managed to do it for the part one part (i.e for the choice == 1)

I can repeat it for the other choices (i.e for 2, 3 ) but I do not want to repeat the code and do it in a different function or do it once for all. While making an attempt I can not handle the rest of the program and all the program turns into a mess.

#include <iostream>
#include <fstream>
#include <iomanip>
int menu();
int myChoice(char);
char inputValidating();

[Code] .....

Need Error handling for file opening and Reading that is used once, So far I have managed to do it for choice 1

Text file can be found in the attachment

View 3 Replies View Related

C++ :: Conversion From PDF To Text File

Feb 25, 2013

I have this project, How do I ever Convert a .Pdf file to .txt file using C++.

View 5 Replies View Related

C++ :: I/O Text File Handling And Dynamic Memory Allocation

May 19, 2014

I am working on an OOP assignment (text handler) which part of its description is:

Some lines of text as a story which the delimiter between each story is %%%%%

Each text loaded should only occupy the space needed for the text to fit.

It's required to use dynamic variables of type char*. To be more detailed, the text-handler must contain a vector of such char-pointers (i.e. c-strings), and the parameter in the constructor indicates how many pointers (c-strings) to be contained in the vector. Each loaded text will be represented by a number, so that the first text in the file gets number 0 and the next one gets number 1 ... etc. When you want to access a text, you request the text with a certain number, and then get a pointer in return that may be used to output the text on the screen.

My problem is first to allocate a dynamic memory like char** without defining the number of array elements (Each text loaded should only occupy the space needed for the text to fit. )and then store each story from text file (comprise of a few lines of text) into that dynamically located memory(char **)to be able to do some operation on it later.

View 15 Replies View Related

C++ :: Document File To HTML Conversion

Sep 14, 2013

I have a program that converts document files to html , however there's a very strange issue with the program, it is only converting files that i open within the program using fstream i.e. ofstream out("test.doc"); now ill have to copy the contents from another document that i want to convert to this test file and it would convert but if i try converting a document that has not been implicitly created it would give me a garbage .html file.

#include <iostream>
#include <fstream>
#include <cassert>
#include <string>
#define tab "    "

// file extensions that the program can handle
// you can add more extenssions if needed
using namespace std;
char *fileExt[] = {".doc", ".c", ".cpp"};
void convert_to_html(string fileName);

[Code] ....

View 3 Replies View Related

C++ :: How To Search Form Insensitive To Case Sensitive - File Handling

May 23, 2014

How to search form insensitive to case sensitive? I'm trying to emulate the behavior of the function "grep" in Unix.

#include <iostream>
#include <fstream>
#include<string>
#include<vector>
#include <ctype.h>
using namespace std;
int main(int argc, char** argv) {

[Code] .....

View 3 Replies View Related

C# :: Multiple Tables Conversion From Excel XLS File To XML With OpenXML

Apr 25, 2014

I have downloaded this project from here -->> [URL] ....

This one works fine and it's a great commented code to understand even for beginners like myself, but it only works with one table per sheet. Once I add second table in sheet, it throws an error that something is wrong in one of the columns in my spreadsheet: It says: " Error occurs! The error message is: Cannot find column 4. "

Basically, I have this type of tables in my spreadsheet:

So I want that my program would export those two tables in a single .XML file (just read them both). And those two tables should be separated in two XML childs: the upper one should be Order-Header and the lower one - Line-Items, like this:

<ROOT>
<Order-Header>
.....
</Order-Header>
<Line-Items>
.....
</Line-Items>
</ROOT>
ConvertExcelToXML.cs:

[Code] ....

I copied all the code because I think it is the easier way to spot where to change it, to read those two tables in one spreadsheet and export them both in one XML file. How could I achieve this kind of functionality.

View 14 Replies View Related

C :: File Operations - Fwrite Padding Extra Data In File Compare To Data Provided As Input

Oct 28, 2014

I am trying to write my files to another subfolder . Below is my program.

Code:
cat th6.c
#include <pthread.h>
#include <stdio.h>
#include <string.h>

#define SIZE 8
#define NUMELM 8

[Code] ....

I observe my filename along with directory as text in the new file created in sublfolder. This is output.

[cporgs/apue/threads]: mkdir first
[cporgs/apue/threads]: ./a.out test.txt first
test.txt -- first/test.txt
dfdfdfdfdfdfdf-14
dfdfdfdfdfdfdf-14
in thread test.txt first
[cporgs/apue/threads]: cat first/test.txt
dfdfdfdfdfdfdffirst/test.txt
[cporgs/apue/threads]: cat test.txt
dfdfdfdfdfdfdf

I could not able to get from where this filename and folder is getting added.

View 4 Replies View Related

C++ :: Input Data From File / Write Data To File

Mar 8, 2013

Ben has been administering a MBTI personality test. Now he has all the responses, but the task of scoring and compiling results seems daunting. The personality test* is a series of 70 questions for which the available responses are ‘A’ and ‘B’. Based upon the answers to the 70 questions, a personality profile is determined, categorizing the degree to which the responses place the person on four scales:

Extrovert vs. Introvert (E/I)
Sensation vs. iNtuition (S/N)
Thinking vs. Feeling (T/F)
Judging vs. Perceiving (J/P).

Each of the 70 questions relates to one of the four scales, with an ‘A’ response indicating the first of the corresponding pair (E, S, T, or J) and a ‘B’ indicating the second (I, N, F, or P). For instance, an ‘A’ response on the question: At a party do you:

A. Interact with many, including strangers
B. Interact with a few, known to you indicates an Extrovert rather than an Introvert; just the opposite for a ‘B’.

For this test, each question is designed to influence one of the four scales as follows:
questions 1, 8, 15, 22, 29 … are used to determine E/I,
questions 2, 9, 16, 23, 30 … and 3, 10, 17, 24, 31 … to determine S/N,
questions 4, 11, 18, 25, 32 … and 5, 12, 19, 26, 33 … to determine T/F, and
questions 6, 13, 20, 27, 34 … and 7, 14, 21, 28, 35 … to determine J/P.
Notice these come in sequences of “every 7th” question.

The goal of the test is to determine which end of each of the four scales a person leans, and to thus classify him/her based on those leanings (e.g., as ENFJ, INTJ, etc.). Since Ben would also like an indication of how strongly the test taker fell into each of the four, the program should print the percentage of ‘A’ responses for that scale.

Input for this program should come from a file responses.txt. The first line of the file will contain a single integer, n, indicating the number of test results to follow. Each of the following n lines will contain the first name of the test taker, a single blank, his/her last name, a single blank, then the 70 responses he/she gave on the test. Although the test instructions indicate that the results are most valid when all questions are answered, sometimes respondents leave questions blank. In that case, a dash appears at the corresponding place in the list of responses.

Output for the program should be written to the file types.txt. It should include a well-formatted report listing, for each test taker, his/her name, the percentage of ‘A’ responses in each scale, and the resulting personality type. A tie within a scale should result in a dash (‘-‘) for that part of the personality type.

View 2 Replies View Related

C++ :: Stream Data To A File And Then Return To File To Add Further Data?

Aug 23, 2012

I am trying to stream data to a file, and then return to the file to add further data. When I add data the second time, I then want to update the value of the second byte in the whole file. I can't seem to do this!

Here is my sample code:

Code:
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
int f = 6;
int g = 7;
int x;
fstream out1("file.dat", ios::out | ios::binary | ios::trunc);

[code]....

The output I get is "1, 2, 3, 4, 5, 6", but I want to be getting "1, 7, 3, 4, 5, 6", because in "out2", I seekp to the second integar entry, and change it to "7".

I have also tried using ios::ate in the constructor for "out2", but this gives me the out put "4, 7, 6, 6, 6, 6", which is suggesting that when I create my fstream object "in", any seekg commands are relative to the beginning of the "out2" stream, rather than the "out1" stream.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved