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
ADVERTISEMENT
Nov 12, 2014
I have been asked to create a program that accesses an inventory file done in excel, look for a alpha-numeric code, which will be inputed by the user, and return to the user informations related to the position of that code, and informations related to the header of the column in which the code resides.
An example of the function I need the program to perform would be:
User inputs: 1429-R1
And the program returns: Marco's 6A, 8/21/2014, 3/7/2014.
using the following example of file:
Marco's 6A
Assessment 8/21/14 3/7/14
1584-R1 1584-R1 1584-R1
1461-2R1 1461-2R1 1461-2R1
1429-R1 1429-R1 1429-R1
View 1 Replies
View Related
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
Aug 28, 2014
I am completely baffled by bin file read/write and positioning. Here I wish to search a chemical name info by symbol. Here is my struct
struct chemicalElement {
int atomicNumber;
char name[118];
char symbol[3];
float mass;
};
I successfully wrote to file.dat as binary but having problem in reading and searching...here is my func...
void searchSymbol(char sym, chemicalElement chemEl[]){
ifstream binFile;
unsigned short int i=0;
binFile.open("chemicalEl.dat", ios::binary);
if(binFile.good())
cout<<"File read for search"<<endl;
[Code]..
View 5 Replies
View Related
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
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
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
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
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
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
Aug 13, 2013
I'm intrested in creating programs of games and such which learns while playing and saving the information for further use. For example a tic tac toe game where the program saves evry game it won or lost and creates a tree of some kind that store the information of the game and save it in a file when the program is being quit. The problem i'm having is how to save a tree in a file efficently.
View 2 Replies
View Related
Apr 19, 2013
I have a tab separated file that consists of 10 columns. (classical txt file).the third column is the one interesting to me it consists of some strings like :
Code:
2313 234ffer string1 sd33 ...
2313 234ffer string1 sd33 ...
2313 234ffer string2 sd33 ...
2313 234ffer string1 sd33 ...
2313 234ffer string2 sd33 ...
2313 234ffer string1 sd33 ...
2313 234ffer string3 sd33 ...
according to the value in the third column i wish to split my text file sot that i have files string1.txt string2.txt and string3.txt such that each file contains the whole line. how to do it in c++ with hash tables (maps) and all those fancy tools all ready and waiting for me to use them but in c i am crippled.
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "strmap.h"
[code]...
My idea was to first go through the file, hash all values in tht third column so i get a unique set of elements and then for each distinct string(element) in the third column create a file pointer, then go once more through the file and as I encounter a specific string(element) type, write the whole line into the appropriate file.
View 9 Replies
View Related
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
View Related
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
Apr 4, 2013
I'm trying to read information from a file and put the data into vectors of its appropriate type. For example: the file will have an int ID, string firstname, string lastname, double salary, int hours_per_week, and string work_position. All this data is separated by ";". I don't know how to read this file into the appropriate vectors: vector<int> ID, vector<string> fname, vector<string> lname, vector<double> salary, vector<int> hpw, vector<string> work.
View 8 Replies
View Related
Dec 8, 2014
I am trying to use a combination of windows batch scripts as well a C++ program to put users data into one single .CSV file. Right now, I have a batch file that will output data from the command line into multiple .txt files. These files are mac.txt, serialnumber.txt, computermodel.txt, and computer name.txt. What I want to do, is to have users run the batch file, which will in turn run the .exe C++ file which will concatenate all their data into one file, computerinfo.csv. The file format for this file would be to have the mac address, serialnumber, computer model, and computer name all in their own column.
My main issue is that these individual files don't have the format that I would like, but based on the command prompt functions, there isn't really any good format. For example, the mac.txt file has the following format:
Physical Address Transport Name
=================== ==========================================================
xx-xx-xx-xx-xx-xx DeviceTcpip_{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
yy-yy-yy-yy-yy-yy Media disconnected
zz-zz-zz-zz-zz-zz Media disconnected
but all I really want is xx-xx-xx-xx-xx-xx
The other files have other issues with format, but if I can figure out this one then the others should be a piece of cake.
Also, I want the output of this to all go in one row, and as other users run this file, they will go into new rows without touching the rows above.
View 1 Replies
View Related
Nov 9, 2014
What I want to do is create a file that will ask the user to enter his info,n then store it in a text file The screen will ask the user if he wants to update his info. if he says yes then the screen will be cleared and the old info will be printed on the screen. The user will enter his new info that will be stored in a new file. My problem is that once the user finishes entering his input the program just closes D: and the rest of the program won't run.
Code:
int main()
{
string ans;
ofstream Xfile("original.txt");
cout <<"Enter your name and address please"<<endl;
cout<<"Press Ctrl+Z+Enter when you are done"<<endl;
string name_and_street;
[Code]...
View 3 Replies
View Related
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
Mar 7, 2013
I am trying to implement a Task scheduler where i have n number of tasks. The Idea behind my task scheduler is that in a loop of queues of a vector, task should get enqueued to the shortest queue among the loop of queues, which is done by the following code.
#include <vector>
#include <queue>
std::vector<std::queue<int> > q
int min_index = 0;
task t // implemented in the other part of the program
[Code] ....
Next i am trying to extend this paradigm to reduce the overhead time of the scheduler, Instead of searching the shortest queue every time, search after some condition ie. search the shortest queue after 5 tasks gets enqueued to the shortest queue.
i need to do something like this
#include <vector>
#include <queue>
std::vector<std::queue<int> > q
task t // implemented in the other part of the program
while(q[min_index].size()!=q[min_index].size()+5) // check whether current min_index queue's size is increased 5 more times if not goto enqueue
[code].....
View 1 Replies
View Related
Aug 22, 2014
I should state that I am recently new to C programming. I have dabbled with Python in the past, but nothing formal. I am taking a C programming class, but it is an introductory course. As such, the instructor is moving extremely slow through the material.
With this program, I am trying to search a given text file (line-by-line) for user-submitted data. I then want to be able to store which line that data was found on. The program runs, but it always results in "Sorry, couldn't find a match." Even if it shouldn't.
Code:
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
}
[code]...
I should probably explain my overall goal with this program.I would like to write a program that will calculate the molecular weight of a compound. I expect the user entered molecular compound to be something like this: CH3COOH (An equivalent entry could be C2H4O2)Also, it needs to be case sensitive because the chemical formulas are case sensitive.
The output will be "The molecular weight of CH3COOH is xxx.xxxxx grams".I have two text files as well. One contains a list of all chemical symbols, and the second is a list of all atomic weights in the same order as the first. I want to place the user inputted data into an array, then search for each element of that array in the chemical symbol text file. It will show which line it was found on, then I can use that line to grab the atomic weight from the second text file.
View 5 Replies
View Related
Jan 12, 2013
How I can search a sub string in a file? Length of sub string is Variable and the number of search is indefinite.
View 15 Replies
View Related
Apr 4, 2013
#include <iostream>
#include <cwchar>
#include <string>
#include <Windows.h>
using namespace std;
#include <shellapi.h>
#pragma comment(lib,"shell32.lib")
static HWND hBut;
#define ShellExecute;
[Code] ....
My function is the issue. I'm not sure how to write a correct function to search your computer for file 'a'.
View 3 Replies
View Related
Aug 10, 2014
Below is a snippet of my code in which it loops through a file trying to find the matching record of a selection given by the user. I use tellg() to tell me where the search begins and it does in fact start at the beginning. But when the search actually executes, it starts at the last record, loops once, and ends, as it does not find the matching record (when the user enters '24' for example)
void Hardware::updateExistingRecord(ofstream &addRecordInfo, ifstream &updateRecord, Hardware &_records) {
//selection on which field to update
enum Field { RECORD_NUMBER = 1, TOOL_NAME, QUANTITY, COST, EXIT };
cout << "Enter record number you would like to update
";
cout << "Enter zero to exit
?";
[Code] ....
View 10 Replies
View Related
Mar 24, 2012
I'm trying to search a specified file for all instances of substring "abbaa."
The professor is making us use a 6x3 array in order to understand finite state machines.
Well the code I wrote runs perfectly, but the case for '/n' doesn't catch. It just flows through without it.
Significant portion of code:
Code:
if(fin) {
fin >> inChar;
while(fin) {
switch(inChar) {
case 'a':
currentState = state[currentState][a];
[Code] .....
View 3 Replies
View Related
Sep 16, 2013
Write a program to find the number of comparisons using the binary search and sequential search algorithms
//main.cpp
#include <cstdlib>
#include <iostream>
#include "orderedArrayListType.h"
using namespace std;
int main() {
cout << "." << endl;
[code]....
View 4 Replies
View Related
Oct 7, 2014
inputting a search array. I tried putting a binary search but I can't get it to work. everything else works up until I put the value I am searching for in the array, then it just crashes.
How it suppose to work: input 2 coordinates with a value each then it calculates the distance between them then it suppose to let user search the coordinates for a value and state if found which coordinate it is at.
#include "stdafx.h"
#include <iostream>
#include <iomanip> //for setprecision
#include <math.h>
[Code].....
View 3 Replies
View Related