Visual C++ :: Program To Output A Line For A Specific Age Group - CPP File

Feb 13, 2013

I am suppose to make a program that will output a line for a specific age group,but everytime I execute the exe file it gives me the desired line and also the last line included everytime.Where did I go wrong with it including the last line everytime?

#include <iostream>
using namespace std;
int main() {
double age;
cout<<"Enter your age:";
cin>>age;
if (0<age && age <6)

[Code] ......

View 1 Replies


ADVERTISEMENT

C/C++ :: Delete Specific Line In Text File Using Program?

Feb 6, 2014

Some codes to delete a text in a specific line in a text file.

Example:
This is line 1
This is line 2
this is line 3

Removing line 2,

This is line 1

This is line 3
//////////////////

View 2 Replies View Related

C++ :: Reading Group Of Numbers Per Line In Text File

Mar 27, 2013

I am working on a project for school that has us read in a text file that contains 8 lines of SSN and grades. I am not sure how to go about reading in the lines and differentiate between the SSN and grades in the calculations.

View 1 Replies View Related

Visual C++ :: Letting User Enter A Character On Specific Line And Place?

Aug 8, 2014

How can I create in my C++ program so a user can paste a text and then choose a character on specific line and place?. The above thing isn't that important. I just want to place a character on a specific line and place.

I mean something like this:

Enter a character:

You choosed " / "

On which line do want the character?

You choosed "Line 1 and 2"

Where do you want the the to appear on the line? (left or right)

You choose left.

Results:

Line 1. / hello

Line 2. / hello

View 8 Replies View Related

C++ :: Program That Prints Prime Factors Needs To Have Them Output In A Specific Way

Jan 6, 2015

I am working on an assignment to enter a number and print all the prime factors of that number. I have that working, but the assignment demands the output be formatted in a strange way which I can't figure out. For example, in my current program entering 10 gets me 25, which is actually 2 and 5. But it should get me: ( 2 * 5 ) but I can't figure out how to do this. On the chance you need it, my code is below:

Code:

#include <iostream>
using namespace std;
int main( )
{
cout << "Number: ";

[Code].....

View 12 Replies View Related

C# :: StreamReader And StreamWriter - Overwriting Specific Line In A File?

Apr 10, 2014

I am currently working on a small project, which is an ATM simulator but, lately, I've been stuck in a part where I have to overwrite a specific line in a .dat file to update the account's checking and savings balance, once the transaction has been done. I have to use StreamReader and StreamWriter to complete the task and I have also being told to try Collections... which I'm not sure as to why.

Here's my code so far:

private void btnOKd_Click(object sender, EventArgs e) {
int transaction = 0;
atmTIMER.Elapsed += new ElapsedEventHandler(timerRESTART);
FileStream fileTRANSACTIONS = new FileStream("C:\Users\Voyage\Desktop\ATMSim\ATMsim\Transactions.dat", FileMode.Open);

[Code] .....

View 14 Replies View Related

C++ :: Traffic Control Program - Output Data At Specific Time

Oct 24, 2013

I was given an assignment to create a simple program for traffic control. How should i output data at a specific time, for e.g a driver approaches an intersection, the yellow light will flash indicating that he needs to slow down and then the red light to stop before taking a route. is there any function i can use to output red light a few seconds after yellow light.

View 10 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

Visual C++ :: Sum Multiple Group To Find The Max

Dec 17, 2013

How to sum groups in C++? I have a class with 2 attributes (Group and Price). I need to find the group with the highest amount. I can find the max when it comes to finding a set of individual numbers but not when a group is required. For Ex:

Group A64
Group A48
Group A18
Group B49
Group B36
Group C64
Group C75
Group C87
Group C72

The group with the highest amount is GROUP C

View 14 Replies View Related

C++ ::  Going To A Specific Line Through Ifstream

Jan 12, 2015

I want to access specific lines in a "*.txt" file. I've heard of seekp() and what not, but don't know how to call them as such.

View 6 Replies View Related

Visual C++ :: How To Detect Multicast Group Address

Nov 13, 2013

I have a problem with UDP Multicast. I managed to send UDP Multicast telegrams and receive them. But when I receive the telegram I need to find out to which multicast group address it was sent. So far I have:

Code:
recvfrom( hSocket,
pcData,
nMaxDataLen,
0,
(SOCKADDR*) &from,
&len);

When I read from.sin_addr.S_un.S_addr; then I get the original IP Adresse from the sender PC but I also would like to know to which group address it was sent. Is there a way to get this infoamtion?

View 3 Replies View Related

C++ :: Processing Large Files - Getting A Specific Line

Jul 5, 2012

I am reading in some large files to process. The files need to be parsed into multi-line sub units for processing (by a different physical process). My current setup is crude and parses the entire file into memory before beginning to process the sub units. This is fine as long as the file fits, so I get into trouble > 2GB or so when my machine flat runs out of memory. The simple thing to do is to only read in some of the file, process what was read in, and then read in more. I more or less know how to stop reading at some point in the file, but I'm not sure how to resume from that point later when I need more data. Is there a way to count lines and then getline() starting from a specific point in the file? From reading the getline() doc, it doesn't look like there is.

This is my current function,

Code:
void ParseFile(char *path, char type) {
// open input file
ifstream input_file(path);
if( !input_file.good() ) { cerr << "Failed to open " << path << endl; exit(ERRCODE_ERROR); }
int pos = 1;

[Code] ....

I need to remove the code to open the file from this function and open it elsewhere. I would like to call this every time I run out of data, if( tasks.empty() ), and get more data from the input file, but I don't know how to resume reading the input file from where I left off.

If this is not possible, I guess I would have to place a function call in while( input_file.good() ) to call out and process the data I have. When the current tasks list is finished, the list could be cleared and control returned into the while loop to continue reading input and start re-populating the list.

View 2 Replies View Related

C++ :: Write Program That Reads Group Of Chars?

Nov 28, 2014

Write a program that reads a group of chars till $. Then, compute # of vowels, # of digits, # of word and # of special chars. Your program should display all required results.

So in what way should I do it? Loop, array, ...?

View 13 Replies View Related

Visual C++ :: Edit / Update And Display Group Of 40 Parameters On Screen

Feb 26, 2014

I need to edit ,update and display a group of 40 parameters on screen. (10 parameters per page and use of Arrow Key pad or touch screen clicks to modify value)....

For that I will need .. Parameter No . , String Name , Point Screen Cord , double value , next element no. etc I have my old code with structure and array of structure written in C. I have translated it on C++/MFC .

How can I implement Class property of c++ ?

View 8 Replies View Related

Visual C++ :: Replace Particular Line In A File

Jun 29, 2013

I want to read a file and replace a particular line in a file.

Ex:

temp.txt file contains below

FilePath1: xxxxxxxxxxxxxxxxxxxxxxxxx
FilePath2: xxxxxxxxxxxxxxxxxxxxxxxxx
FilePath3: xxxxxxxxxxxxxxxxxxxxxxxxx
Mode: 1

Here My requirement is replace the 4th line Mode: 2 instead of Mode: 1.

I was used seek method like below,

Code:
CStdioFile SaveFile;
CString strFilePath;
strFilePath = _T("C:Sara emp.txt");
if (SaveFile.Open(strFilePath, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite), &fileException) {

[Code] ....

The above code not working correctly.

View 14 Replies View Related

Visual C++ :: Program That Reformat And Output Date

May 30, 2013

Write a well-commented C++ program that reformats and outputs the date. Prompt the user to input the date in the format dd/mm/yyyy and outputs it in this format month, dd, yyyy. For example, 07/06/2012 is displayed as June 07, 2012. You are provided with the file months.txt containing the months and their corresponding numbers, for example 01January 02February etc. Use getline(monthsFile,monthString) to read in a string from the file, and use the monthString.find() function to search for the number and extract the corresponding month.

-confused by the way she told me to use getline(monthsFile,monthString) => if I just do it like this I only get the first line from the txt file (01January)
-if I try putting all the months on one line in the txt file (which i'm not even sure i'm allowed to do), I'm not sure what to do for the length of my substring output. if I make it long enough to fit longer months like September, someone entering may gets both may and june in the output
-if I input all the months into separate variables, I'm not sure how to make it only output the month entered by the user

the months.txt file is as follows:

01January
02February
03March
04April
05May
06June
07July
08August
09September
10October
11Novmber
12December

View 1 Replies View Related

C :: Program Not Read The First Line Of File

Dec 2, 2013

I have been working on a program to scanfile and whenever it encounters what the user wanted it prints it, and it is all right less the first line of the file that the program jumps,

Code:

#include<stdio.h>#include<string.h>
#include<stdlib.h>
void main()
{
unsigned int j=0 ;
char num[100] , str1[100], str2[100];
FILE *fp;

[Code]....

View 3 Replies View Related

Visual C++ :: Payroll Program Is Showing Zero In Output Section

Nov 25, 2013

The program is showing zero in output section ....

Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;

[Code] ....

The output:

Code:
First Last Employee Hours Rate Regular Overtime Gross
Name Name Number Worked of Pay Pay Pay Pay
==============================================================
Jane Adams A1234 40.00 10.00 0.00 0.00 0.00
Mary Lincoln L8765 50.00 10.00 0.00 0.00 0.00
Martha Washington W7654 25.50 10.85 0.00 0.00 0.00
John Adams A9876 52.00 15.75 0.00 0.00 0.00
George Washington W1235 45.00 25.00 0.00 0.00 0.00
Abraham Lincoln L9087 40.25 55.00 0.00 0.00 0.00
William Tell T9876 30.00 9.75 0.00 0.00 0.00

View 12 Replies View Related

Visual C++ :: Loading A File And Indexing Line Starts

Jun 14, 2013

I've spent some time trying to performance test various methods of loading / accessing a file, either into memory or through a memory mapped file, but I am having some trouble.

FILE * pFile;
std::ifstream ifs;
MapViewOfFile

I'm have trouble because Windows appears to cache the file, so I am getting very mixed results. Sometimes a huge file (100's MB's) will load quickly, other times almost instantly.

How to stop Windows from doing whatever it's doing, so I can see the real time taken to load/access a file from disk?

View 8 Replies View Related

Visual C++ :: Detect ItemID And Delete That Line From File

Oct 14, 2013

I have a text file name fruit.txt that contains the following information of fruit id, fruitName and fruitQuantity.

Code:
1:pear:30
2:apple:20
3:banana:24
4:orange:15
5:watermelon:35

If let's say I key in 2, it will search for the id=2 and delete the whole line and the id of banana which is orignially 3, will become 2 and orange which is orignally 4 will become 3 etc.

I researched on how it can be done and most suggested to put inside a vector and fout the line.

I know how to put the values in the vector but how should I go about searching for the id and if the id is found it will delete that line inside the file.

Code:
ofstream fout;
ifstream readFile("fruit.txt");
while (getline(readFile, line)) {

[Code]....

View 2 Replies View Related

C :: Program To Calculate Students Grades From Input File And Write To Output File

Aug 29, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows:

John K. 99, 87, 57, 89, 90, 95
Amanda B. Jones 100, 88, 76, 99, 86, 92
etc..

The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the last (2) at 30% each.

Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

[Code]....

View 2 Replies View Related

C++ :: Program To Delete The Sixth Line From A File

Nov 18, 2013

How to use these functions: fread, fclose, fseek, ect.

Q1) Write a program to delete the sixth line in a file. Do not change the sixth line to a blank line; delete it completely.

*** this one I was able to replace the file with what I wanted but realized it needs to be deleted ***

Q2) Write a function that deletes the last line of any file.

*** this one didn't even know where to start ***

View 3 Replies View Related

C/C++ :: Program Cannot Find Words In The File If They Are On Another Line

Apr 3, 2015

I wrote this code to search words in the file and display if the program found the word or not. when i write the words in the file on the same line (without the endl) like this :

w_toFile << "gilbert";
w_toFile << "lara";
w_toFile << "rana";
i can search any word.

but when i write them with the endl, the program can find only the first word. what can i do to make the program find any word even if they are each on a line?

here is the full code:

#include <iostream>
#include <windows.h>
#include <fstream>
#include <string>
using namespace std;
int main (void) {
string wordsearch;

[Code] ....

View 5 Replies View Related

C++ :: Program That Deletes Two Spaces On Each Line In A File

May 17, 2012

I must create a program (a simple main.cpp in console interface) which deletes two spaces for every newline in a file. If a line has no space, it goes straight to the next line to the end of the file. After the program is to resave the file contents into a new file that has the same name as the old, but change the extension to. Modif

The problem is I can not do that ... Do you have a sample code that does this?

View 3 Replies View Related

Visual C++ :: Enter File Name By Keyboard Instead Of Command Line Arguments?

Mar 10, 2013

Actually the below program is for Dispersal Algorithm called Rabin-IDA; this algorithm divided the data into N pieces and then recombine it from M pieces (such that M<N).

Thus, the below program needs command line arguments,which entering by Project properties/Debugging. this argument is file name, where the program performing spitted the file into N files, and then recombine it from M divided files, and put it on another file which should also passing its name as argument .

Now my question is, How can i make this program enter the file name by keyboard??(i mean enter the files name by user from screen not as command line arguments) ... In another word, How I can exchange ?

Code:
argc == 3
and
Code:
argc == 2

To enter file name ? i mean what i should do to in

Code:
rabin.split(argv[1])

To pass my file name by use keyboard not Project properties/Debugging?)

the below code is just the main function of program, and the whole of it in this link [URL] .... Information Dispersal Algorithms Rabin-IDA.

Code:
#include "include.h"
void __cdecl _tmain(int argc, TCHAR *argv[]) {
DWORD ini=GetTickCount();
try {
if( argc == 3 ) //recombine

[Code] ....

I know I should use getline() function but how exchange argv[] ?

View 1 Replies View Related

C/C++ :: Program That Count Empty Line And Display Whole File

Jan 6, 2015

I am new in c programming. I want to write a function that will count the empty line of the file and display the content.

/* ***************************
** creator: firstprint *
******************************/

#include <stdio.h>
/* function that will identify if line is empty or not */
is_empty(char *buffer) {
while(isspace(*buffer)) buffer++;
if(*buffer==0x00) return 1;

[Code] ....

View 4 Replies View Related







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