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


ADVERTISEMENT

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/C++ :: Program To Scan Number And String Then Print Them To A File

Mar 19, 2015

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??

View 3 Replies View Related

C :: How To Scan Text File And Put It Into Array

Mar 4, 2013

This is my text file.

bak kut teh[tab]888.0[tab]989.0
spicy chicken nugget[tab]999.0[tab]978.0

I'm experiencing some problem in trying to scan and put it into an array for the food names (e.g an array for food which consist of bak kut teh and spicy chicken nugget) and another 2 array for the other individual integer into C. However there seem to be some problem with my code.

Is there a difference if I use both tab and space instead of space for all?

Code:
#include<stdio.h>
int main() {
FILE *fp;
char food[100];
char buff[BUFSIZ];
float num;

[Code] ....

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++ :: 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 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 :: How To Scan And Print Integer

Jan 28, 2013

This is my code:

int main() {
int num;
printf("Please enter a number: ");
scanf("%d", num);
printf("%d", num);
return 0;
}

when i compile and run it, it stops working and doesn't printf the integer.

View 3 Replies View Related

C Sharp :: Display MySQL Database Table User Info?

Aug 18, 2012

I was looking at this code:

private void button1_Click(object sender, EventArgs e)
{
string input = textBox3.Text;

[Code].....

And how to rewrite the code so that it display the MySQL table data for a specific user I already have a string called username and that stores the username entered on the login form. I want the code to use the username string to search for the name and display that users info.

My table contents are: username
First name
Last name
Position
Employee Id
Airline

View 7 Replies View Related

C++ :: Using Class Functions To Enter And Print Out Info

May 19, 2013

I have a program that uses class functions to enter and print out info. The problem is with the second function answers(). Here is the whole cpp file. In the answer function I need to use an exception to exit when its the end of an array. I could just be doing it wrong. I used try/catch originally but when I used it, it caught the exception but ended the whole program.

#include <iostream>
#include <cstdlib>
#include "answering_machine.h"
using namespace std;
void AnsweringMachine::init(){
numMessages = 0;

[Code] ......

View 6 Replies View Related

C :: Output Does Not Print On Text File

Jul 19, 2013

In this program I can not print the typed value in the file. The file creation well done but it is an empty file

I press Ctrl +z for EOF

Code:
#include<stdio.h>
int main(void){
FILE *fp;
char ch;
fp=fopen(" Test.txt","w");
printf(" Enter the TEXT

[Code] .....

View 1 Replies View Related

C :: Getting Result To Print To A Text File

Apr 2, 2014

I am having a problem using fprintf. I have a function which flips a coin. Heads prints a text to the screen. Tails prints a different text to the screen. My problem is getting the result to print to a text file.

Code:

#include <stdio.h>
#include <stdlib.h>
#include<time.h>
void seedrnd(void);
int coinflip(int small, int large);
}

[code]....

View 12 Replies View Related

C++ :: Text File - Retrieve And Print Out Contents

Jul 25, 2013

I've created a text file with the numbers from 1-450. After writing code to retrieve and print out the contents in the text file, the compiler only printed out the numbers 124-450. Is there a reason why this is happening?

View 19 Replies View Related

C :: Unable To Read Data From Text File And Print It

May 12, 2014

I am having trouble in reading data from my text file and print it out exactly like how it looks like in the text file. The problem im having is it will not read the last y Coordinates of the point. it keep reading the second last point for y coordinates which is wrong.

my text file is
0.0 0.0
0.0 1.0
1.0 0.0(but it read until here)
0.0 0.0(suppose to read the last point which is here)

For your information, this is my 1st year degree assignment in C programming. It is to create a program which can read text file (manually create) and print it out in a program and calculate the area for the polygon using ADT function ( .c and .h files)

*This is the code for my read file function*

Basically this accepts a Polygon and a file pointer as parameters. It reads the polygon point data from the file, pass the read data to plg_new() to create a new Polygon and returns the new Polygon created.

Code:

polygon *plg_read(polygon *New_polygon, FILE *Coord) {
int i;
int numberofvertices=0;
int count=0;
char filename[50];
double xCoor[50], yCoor[50];

[Code]....

This is the second function my polygon new code. This ADT function basically creates a new Polygon with malloc(), initialize all ADT data members with its parameter values and returns the Polygon.

Code:

polygon *plg_new(double *xCoordinates, double *yCoordinates, int numberOfVertices) {
int x;
polygon *New_poly = (polygon *)malloc(sizeof (polygon));
if(New_poly->xCoordinates == NULL || New_poly->yCoordinates == NULL) {
free(New_poly);

[Code]....

This is the rest of the code if you need to refer to other codings.

Code:
/**
*@file polygon.c
*@brief Functions for polygon / Struct has polygon numberOfVertices, polygon *xCoordinates and polygon *yCoordinates
*@author: Tan Xian Yao
*@id: 4323440
*@date: 22/04/2014
*/

[Code]...

View 6 Replies View Related

C++ :: Create Random Matrix And Print It Out In Text File

Feb 11, 2014

I am trying to create a random 3x3 matrix and print it out in a text file using basic functions. My code below will not compile.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
//nxn Matrix = 3x3
const int ROWS = 3;
const int COLS = 3;

[Code] .....

View 2 Replies View Related

C :: Read Txt File And Print Contents Numbering Each New Line Of Text?

Apr 25, 2013

I have written the following code but i am stuck. Write a program that will prompt the user for a file name and open that file for reading. Print out all the information in the file, numbering each new line of text.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
int main()
{
char line[81], filename[21], c;
int i = 1;
FILE *inFile;

[code]....

View 3 Replies View Related

C++ :: Open A Text File Then Read Data And Print It Back?

Nov 5, 2013

I am in an "intro" C++ course and am having trouble with a section of my current project.

We are required to open a text file, read the data from that file, and print it back.

However, we are supposed to let the user input the name of the file that is to be opened. This is the code I have so far. It is not opening anything.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int NUM_QUESTIONS = 30;
typedef char CharArray[NUM_QUESTIONS];
string fileName;

[Code]...

View 2 Replies View Related

C++ :: Search By Word In Text File And Print Out Whole Line On Screen

Apr 7, 2013

I have a text file where in each line is 3 words and 2 int type numbers. I'm doing search by word and I want to print out to the screen the whole line where that word was found (the words is repeated in some lines). My search looks like this:

Code:
#include<iostream>
#include<string>
#include<fstream>
#include<stdlib.h>
#include <vector>
using namespace std;
int main(){
vector <string> words;
string str, paieska;

[Code] .....

How to print line(s) where I found that word?

View 9 Replies View Related

C++ :: Online Shop - Serious Logical Error

Nov 15, 2013

My project is on an online shop in which you can manage a shop(adding ,deleting ,clearing and modifying items) also you can switch to different shops(all shops are same)

Code:
#include<iostream>
#include<fstream>
#include<conio.h>
#include<stdlib.h>
#include<string.h>

[Code] ....

The logical problem is serious because i am not able to find the error!!! There is some problem with display lines in void shop()-->if(mode=='s') and if(mode=='d'). I add only one item but in output screen i see two items(sometimes >2)
*note* to run the above display lines in the output screen....first register--->add atleast one item--->see your shop

View 12 Replies View Related

C++ :: Add Data To Text Files Which Are Required To Store 3D Scan Data

Jul 10, 2013

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.

#include <string>
#include <locale>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;

[Code] ....

View 1 Replies View Related

C :: How To Scan In Numbers From File And Find The Largest

Oct 4, 2013

I'm working on a silent auction program that will scan a file and find the highest from each group of bids, then have a running total of money made throughout the auction. I'm pretty sure the rest of my code works, i'm just getting stuck on finding the largest number from the line in the file, saving it, then moving to the next auction.

input file text (first number is num of auctions, after that it's num of bids, then the bids):

5 4 100 500 250 300 1 700 3 300 150 175 2 920 680 8 20 10 15 25 50 30 19 23

Sample Output
Auction 1 sold for $500.00!
Auction 2 sold for $700.00!
Auction 3 sold for $300.00!
Auction 4 sold for $920.00!
Auction 5 sold for $50.00!

The silent auction raised $2470.00 for charity!

Code:
# include <stdio.h>
# include <stdlib.h>
# include <time.h>

[Code].....

View 4 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# :: Matching Database Records With RadioButton Text

Feb 19, 2014

I have got 4 radio buttons on my form and & i am trying to match the text for these radiobuttons with a record in one of the database tables. Essentially I would like when the submit button is clicked to match if the selected or clicked radiobutton Text with a database record. And if this matches a messagebox to be displayed saying "match" and if not matched the messagebox should show "no match found"

What I have done so far:

private void button1_Click(object sender, EventArgs e)
{
bool correct;
String Option1 = "";

[Code]....

in this case the "Emp_1" is the matching record , when I run my project when other options or radio buttons are clicked it executes the messageBox showing that it matches even if its not a matching record. What I am trying to say is that it does not execute the else {MessageBox.Show("no match found");} when records don't match.

View 3 Replies View Related







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