C++ :: How To Find And Replace Info In Text File

Jul 1, 2014

I have a program that gives the user the option to create an employee ID, name, address and so on. It also has the option to search employee by employee ID.

What I want to know is how to add and replace employee info. For example employee changes address. Also how to delete employee information from text file.

Here's my code:

//This program uses file input and output for an employee information system.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(){
ifstream inFile; //declare ifstream as inFile and ofstream as outFile
ofstream outFile;

[Code] ....

View 1 Replies


ADVERTISEMENT

C++ :: Find And Replace Employee Information In Text File

Jul 15, 2014

How to search for a word in a text file and replace it with a new one. Such as employee address, or first name, etc.

Here's my code:

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(){
ifstream inFile; //declare ifstream as inFile and ofstream as outFile

[Code] ....

It is under choice 3, most of my program runs correctly but I am just stuck at this part.

View 3 Replies View Related

C++ :: File Writing - Input Your Login Info And Program Writes That Info To A Text File

Jan 30, 2013

I'm trying to make a program that you input your login info and it writes that info to a text file. Then, later on once I get my problem fixed, the program will read the info to the user. my code is as follows(the input part is a bit lengthy):

// Password Log
#include <iostream.h>
#include <fstream.h>
#include <string>
#include <time.h>
using namespace std;
ofstream login;

[Code] ....

What my problem is when I choose "Input new login info" it automatically inputs I have no clue, and calls next program.

View 3 Replies View Related

C++ :: Find And Replace Function For Text Editor

Jan 3, 2013

I'm building a find and replace function for my text editor I'm building the function without support from the algorithm header.

The function is written like: doc.find_replace("Word_to_be_replaced", "The_word_that_is_replacing"); I find this very easy to understand replace this, with this.

find_replace will both have char * as their arguments.

The problem I'm having right now if I replace a bigger word for a smaller word how do I delete the extra characters from memory.

So if I replace "Goodbye" with "Hello" how do I delete the last two characters? So I don't print garbage code.

View 1 Replies View Related

C++ :: Integration With Word - Highlight Text And Offer Find / Replace Functionality

Sep 10, 2013

I'm undertaking a project at the moment which requires me to hook into a custom c++ application from a Java applet via JNI. The c++ application needs to communicate with MS Word and potentially other office programmes in order to highlight text and offer find/replace functionality programatically. The idea is that when the applet is launched, it will communicate with the C++ methods to hook into an open MS Word document and highlight all words that start with the letter 't' for example.

I'm concentrating on the C++ side of things first . Even some basic access to an open word document would give me a great start!

View 3 Replies View Related

C++ :: Find / Calculate And Replace A String In A File

Feb 3, 2013

i have a text file... with example following content:

Pizza 23232
Car 44,495
Drink 3493,90494
....
..
.

and so on..

no i want to find the 44,495 in this textfile.. calculate a new value like 44,495 x 2 + 5

and write the same file as

Pizza 23232
Car 93,99
Drink 3493,90494
....
..
.

back..

View 2 Replies View Related

C :: How To Read Info From Text File

Jan 8, 2014

I'm a beginner at programming and I'm not sure how to read in information from a text file. What I want to do is take a text file which contains around 20 rows and 3 columns of numbers, and put these into an array which can then be used for performing calculations. How do I do this? Would I need to declare the size of the array beforehand? When accessing my file, do I include the full address?

The relevant part is lines 29-33:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* this is a simpllified code using BEM equations */
main()

[Code] ....

View 13 Replies View Related

C :: Why Can't Get Info From Text File Correctly

Dec 21, 2013

the info gotten from the text file are all wrong, i can't find any problem with my code,

Code:

#include<stdio.h>
FILE *f;
typedef struct prd {
char name[30];
char code[30];
char idt[30];
float price;

[code]....

View 7 Replies View Related

C++ :: Replace Some Elements In Text File?

Nov 4, 2014

I have a text file, like that:

(A1*
*
*
*A1)
*
(AM-MNR*AM-MNR)
(V*V)
(C-A1*
*
*
*
C-A1)

Now, I would like to replace some elements, follow the rule:

-(A1* ---> B- A1
- characters "*" following is replace by I-A1
- *A1) ---> I- A1

The output like that:

B- A1
I- A1
I- A1
I- A1
*
B-AM-MNR
(V*V)
B-C-A1
I-C-A1
I-C-A1
I-C-A1
I-C-A1

How can I do now?

My text file have 220 663 lines and 858 995 characters (I used Linux commands : wc to count them. If I use array to store data, I think it's too large array. But if use fstream, I dont know to access each element in stream to compare and replace. I dont know How many labels such as: A1, C- A1, AM- MNR... which I have to replace.

View 1 Replies View Related

C++ :: Read Info From Text File Into Class?

May 22, 2014

I'm having trouble in getting my program to read from a file and put all the proper data into its proper class variables. I have a class (called Champion) that has string variable for a name and a vector of strings for items. I also have a vector of Champion that holds multiple champions. Here's my code:

Champion.hpp
#ifndef CHAMPION_HPP_INCLUDED
#define CHAMPION_HPP_INCLUDED
#include <iostream>

[Code].....

View 3 Replies View Related

C :: Search Table And Replace Values In Text File

Feb 3, 2015

I have to develop a C program that reads a very complex txt file (output of a calculation code, so full of mixed text and numerical tables), search for a specific table in it and individuate/print or replace a specific value with assigned position in the table.

View 2 Replies View Related

C++ :: Shop Database - Take Customers ID And Scan Through A Text File Then Print Out Info

Apr 10, 2013

I have to create a small data base for a shop. One of the functions i am creating is taking a customers ID and scanning that through a text file and to print out the info about that customer. What i am having trouble with is where do i insert the string compare in my program?

//declaring array for input of customer ID
int customer_ID [20];
printf("Please enter the customer ID:");
gets( customer_ID ); //users input stored in the array

[Code] .....

View 2 Replies View Related

C++ ::  pass Parameters From Other Application To Replace String Within Text File Before Execute Registry Merge

Jan 27, 2014

I'm creating simple console application using Code::Blocks to allow me to pass parameters from other application to replace string within text/registry file before execute the registry merge. Passing parameters to console already success. Now I only have problem with reading file. Example of first line in the registry file is as below.

Windows Registry Editor Version 5.00

However when read into string and output to console using 'cout', it will be show as below with spaces in between.

W i n d o w s R e g i s t r y E d i t o r V e r s i o n 5 . 0 0

Below is my code.

ifstream f("install.reg");
string s((istreambuf_iterator<char>(f)), istreambuf_iterator<char>());
cout << s;

View 6 Replies View Related

C# :: Find And Replace Box For Notepad?

Feb 20, 2014

How to design Find and Replace Box for notepad using Windows Forms

View 3 Replies View Related

C++ :: Find First Non Zero Element In Array Then Replace With NextCard

Dec 8, 2014

I'm trying to find first non zero element in an array then replace the zero with nextCard. it just will not work.

void addToHand(int hand[], int cardToAdd) {
int i=0;
while (hand[i]!=0) {
i++;
} hand[i]=cardToAdd;
}

View 2 Replies View Related

C++ :: String Find And Replace (Modified To Upper Case)

Feb 3, 2013

"C++ is a general-purpose programming language." I have to find the word "C++" and replace it with "Java" and then capitalize all letters.

#include <iostream>
#include <string>
using namespace std;
int main( ) {
string origin; //contains input string
string replace; //the string obtained by replacing "C++" with "Java"

[Code] ....

View 1 Replies View Related

C :: Find The Maximum Value In A Column Of Text File

Jul 28, 2014

I have problem with finding the maximum value in a column. This is my code

Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *fp;
fp = fopen ("C:
ocket1.txt", "r");
float time, altitude, velocity, acceleration, amax, bmax;

[Code] ....

The first loop will print out all of numbers in the velocity column. The second while loop is looking for the maximum value in that column. It is supposed to print out the max velocity in the end of the second loop. However, when I build and run the program, it's crashed. I run debugger and received "Segmentation fault" error. When I eliminate the second loop, it run just fine I use Code::Block for text editor.

View 8 Replies View Related

C++ :: Function To Find Sum Of Certain Word In Text File?

Jul 26, 2014

I've written a function that has to receive a word as parameter, and then has to find the amount of times that word (uppercase & lowercase) occurs in a text file:

For example, if the word "the" is sent as a parameter, the total amount of times the words "the" and "THE" occurs in the text file, has to be calculated.

However, my function is not displaying the correct amount, what is wrong with my function:

int WordCount :: countWords(string wrd)
{
int counter=0;
string temp = "";

[Code].....

View 1 Replies View Related

C++ :: Use Find Function To Search For A Line In Text File

Oct 28, 2013

I'm trying to make a program that will search for a line in a text file using a non default delimitor at the start of the line. An example line in the text file would be as follows:

F Mary Smyth, 19, United Kingdom

I have been able to use the find function to search for and return the 'F' character but would like it to then display the whole corresponding line. Is this possible with the find function?

ifstream readFromFile("data.txt");
string Destinations[1] = {"F "};
string data;
while(!readFromFile.eof()){
getline(readFromFile,data);

[code]...

View 2 Replies View Related

C/C++ :: How To Find Top 10 Highest And Lowest Numbers From Text File

Jan 3, 2014

I have a list of numbers with decimal point saved in a text file (grade.txt) like this:

80.2
85.7
57.2
90.0
92.9
74.0
76.5
...
I would like to write a small program to display the top 10 highest and lowest grade points.

View 3 Replies View Related

Visual C++ :: Find Specific String Of Lines In A Text File

Oct 15, 2013

I am trying to print a specific line from a textfile

e.g
I have a text file called info.txt and inside it contains the id,item name, price, quantity

Code:
1,shirt,100,10
2,pants,50,9
3,pen,20,8

I know how to find a specific word at the line in the file but how do I find and print out the specific line e.g(print out just the entire contents of line 2)?

Code:
string temDescription;
ofstream fout;
int curLine = 0;

[Code].....

View 1 Replies View Related

C++ :: Transfer Info From One File To Another?

Jan 18, 2015

I need to transfer the content from the file text.txt to file sort.txt . The data in the text.txt is "struct" (info about people)but the same data needs to be sorted by the name and sent to sort.txt by using a function .

View 9 Replies View Related

C++ :: File Info Search?

Feb 27, 2013

I am looking for a way that I could check the information of a folder and a drive, to show the data size and storage amount (KB, MB, GB). This is so that I can compare the size of a folder to the storage capacity of a disk drive.

View 2 Replies View Related

C/C++ :: Getting Specific Info From A TXT File?

Oct 10, 2014

I'm trying to open a text file with the name "text.txt", for the purpose of only displaying in the console an specific part of the text file. For example, if I got "This is a test [TEXT] This is the message that should display [/TEXT] this is the end of the file", I want only "This is the message that should display" to be the output, the thing is that I can't imagine anyway of doing that. what I should do?

View 5 Replies View Related

C++ :: Change The Version Info Of The File?

Jan 18, 2013

im trying to make a tool that can change the version of the file (.exe)

UpdateResource(hResource, RT_VERSION, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPVOID) lpBytes, dwSize);

i know how to update the rcdata of the resource

my problem is i dont know what to insert to it using (LPVOID) lpBytes is it a .txt ? .rc ? is it a binary ? etc.

View 1 Replies View Related

C/C++ :: Getting Info From Binary File Into A Struct

Apr 19, 2015

Your goal is to open this struct of students (the binary file). Once open, the first job is to print out each student. Afterwards, display all students with a gpa of 3.5 and higher. Finally, display all students with the major of Computer Science or Game Programming. Be sure to title each category of items.

He gave us a .cpp file and a .h file that we're suppose to use to run the program. He doesn't want us to change his original code, except we can add the needed code to run his code (i.e. Struct & Main).

My problem is that I get an Abort() crash message in VS2013 when I try to run it. Now, in line 95 of the cpp file if I replace the char* with "", it runs fine showing the GPA with blank entries for the other print parameters. I've read the Binary Files chapter of the Pearson textbook several times and it doesn't have anything to say about working with char pointers.

Header file:

#pragma once //Professor's code
struct StudInfo //Start of my code {
char* fName;
char* lName;
char* major;
double gpa;

[Code] ....

View 7 Replies View Related







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