C++ :: Saving And Recovering A File Named By User-entered Parameter

Apr 7, 2013

1. How can I save a text file using a parameter which the user entered?

For example, the user enters the word "Johnny". The program will create a new text file "johnny.txt"

2. How do I search the directory for a text file after the user entered a keyword?

For example, the user enters the word "johnny". The program will search the directory and recover the text document "johnny.txt".

View 1 Replies


ADVERTISEMENT

C++ :: Named Parameter Idiom?

Sep 8, 2013

What is the "Named Parameter Idiom" in c++?

View 3 Replies View Related

C++ :: How To Use A User Entered File In Fstream

Feb 14, 2014

So, I am making a name-database-type-thing and I want the user to be able to enter there own file. Like, here:

string fileName;
string name;
cout<<"What is your file name?"<<endl;
getline(cin, fileName);
ifstream nameFile(fileName);
getline(cin, name);
nameFile<<"Name: "<<endl;

Well, that last part is in a loop, so you can enter an unlimited number of names to the .txt file.

So, it won't let me use the string in ifstream. How can I fix this? This maybe unclear, so if it is just say so and I will edit it.

View 6 Replies View Related

C Sharp :: Saving Data In SQL Server Parameter Error Showing

Jun 1, 2013

I have an application with general customer detail.

It has TextBox and radio button.

First I have used if statement then code but on first step is working fine then error is showing.

try
{
if (textBox1.Text == "")
{

[Code].....

View 5 Replies View Related

C/C++ :: Find Max Number Entered By User And Terminate When Negative Number Entered

Jul 15, 2014

I am trying to find the max number entered by the user, and it should terminate when a negative number is entered. For my code, it will just end when the user inputs a lower number than the previous. i.e.- 10 20 15 "The highest number is 20" when it should be "10 20 5 40 15 -1" "The highest number is 40". No arrays or do/while loops either.

#include <iostream>
using namespace std;
int Max(int x);
int main() {
int x;

[Code] ....

View 9 Replies View Related

C++ :: Saving Progress Of A User In Quiz Game

May 5, 2014

I'm making a quiz game in c++. I've already completed it. But now I've thought of creating a profile and saving the progress for the user so when he enters his name the game continues frm where he had saved it.

View 3 Replies View Related

C++ :: Open File Named In Unicode Characters

Sep 22, 2012

How to open a file which its name is unicode letters ? usually :

Code:
basic_ifstream<wchar_t> src("source.txt");

Work well to read file with unicode content not filename, so that example doesn't work :

Code:
basic_ifstream<wchar_t> src(L"source.txt");

Also, I have seen some alternatives for using open function but it doesn't work as well.

Code:
basic_ifstream<wchar_t> src;
src.open(L"source.txt");

I use g++ compiler.

View 3 Replies View Related

C++ :: How Many Entries Entered By The User

Sep 16, 2014

when i declare local variable x and use it in array,the error is occure that use of un assign local variable.

namespace ConsoleApplication11
{class Program
{
static void Main(string[] args)
{
int x;
Console.Write("enter how many entries you want");

[Code]...

View 2 Replies View Related

C :: Checking What User Has Entered (City)

Mar 9, 2013

I am using Dev C++ on a windows computer.

In my code, the user enters the name of a city, and then according to what city it is, the program displays the coordinates of that city

I can't find a way of figuring out and checking which city the user has entered so the code can displays its appropriate latitude and longitude.

View 9 Replies View Related

C++ :: How To Collect Input That Has Been Entered By User

Mar 19, 2013

I am making a program that will suggest meal options when choosing specifics contained within, e.g. style, base, main, sauce.

What I would like to know is how to collect the input that has been entered by the user, say you are given 4 lists and each has an option, how could I chain these together in order to cout a suggestion that is in my database?

-------------------------------------------------------------------------------
Example (not my real Q's and A's):

OUTPUT: What meat would you like?
INPUT: "Beef" //<collect this!
OUTPUT: What sauce would you like?
INPUT: "Tomato" //<and this!
OUTPUT: What would you like to have as the main/base?
INPUT: "Pasta" //<and this!
OUTPUT: I can suggest... "Spaghetti Bolognese" //< and return this from the database using the 3 filters
--------------------------------------------------------------------------------

View 1 Replies View Related

C++ :: Echo String Entered By User

Oct 3, 2013

/*
* echoString2.c
* Echoes a string entered by user. Converts input to C-style string.
*/

#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(void) {
char aString[200];
char *stringPtr = aString;

[Code] ....

and these are my errors

212Untitled1.cpp[Error] stray '222' in program
212Untitled1.cpp[Error] stray '' in program
212Untitled1.cpp[Error] stray '222' in program
262Untitled1.cpp[Error] stray '222' in program
262Untitled1.cpp[Error] stray '' in program
262Untitled1.cpp[Error] stray '222' in program
Untitled1.cppIn function 'int main()':
2125Untitled1.cpp[Error] 'n' was not declared in this scope

View 3 Replies View Related

C++ :: How To Hide Password Entered By User

Jul 28, 2014

I'm making a Project on a Travel Agency and I need to hide the password entered by the user! I am working on Xcode 5.1.1 -> Command Line Tools -> C++ on my MacBook Pro! Here is what I've tried --

string pass ="";
char ch;
cout << "Enter pass";
ch = getchar();
while(ch != 13){//character 13 is enter

[Code]...

But in the first case the display is -

//Assuming the password is Hello Hello ******

And in the second its giving me 3 errors -

1. Apple Mach-O Linker(Id) Error "_stdscr", referenced from:

2. Apple Mach-O Linker(Id) Error "_wgetch", referenced from:

3. Apple Mach-O Linker(Id) Error clang: error: linker command failed with exit code 1 (use -v to see invocation)

View 10 Replies View Related

C/C++ :: Ignore Strings From Being Entered By User?

Oct 6, 2014

how I can ignore strings from being entered by the user. When the use enter's a string it always evaluates it as even. I though I might use a cin.ignore(); but I am unaware of how to use it.

#include <iostream>
using namespace std;
int main() {
cout << "Enter a number: ";
int num = 0;

[Code] ....

View 2 Replies View Related

C :: Error Displaying All Info Entered By User

Mar 4, 2013

Code:

#include<stdio.h>
main() {
int item_code, quantity;
char ans, y;

[Code] ....

View 4 Replies View Related

C++ :: How To Recognize Two Words Entered By User For A String

Feb 11, 2013

In my little experiment i am trying to get the compiler to recognize 1 word with 2 parts from a list of names.

For example: if the user wanted to choose "candy bar", from a list of items which include: "candy bar", "cat", "dog"

My current code can recognize words without a space like cat and dog. But how can i recognize candy bar?

I tried using getline but its of no use.

View 2 Replies View Related

C/C++ :: Creating Constant At Runtime With User Entered Value?

Aug 14, 2014

At the moment I am making program that will use a 2d selection of "cells" to make a "map" of sorts. However, the size will not be known until run time.

I figured using an array would good, because once the size is chosen it won't be changed. However I can't create an array without using a constant.

So the first question is, can I create a constant at run-time with a user entered value that can then be used for an array size? If so, how?

Otherwise, what are my options to achieve this? I know vectors can be used, but A, my compiler keeps giving me problems even when C&P some code bits (yes I even remembered to #include and such) and B, I noticed that vectors reserve extra memory for when the size changes but this is bad (well my dinky little program won't notice, but trying to set good habits as I learn, so I'm keeping it in mind) as I don't need and don't want to allow the size to change after creation.

Which leads to number three, if I do have to use vectors, how can I prevent any accidental size changes after the initial size is determined?

View 4 Replies View Related

C/C++ :: Finding Sum Of Values Entered By User In While-loop?

Aug 26, 2014

Keep track of the sum of values entered (as well as the smallest and the largest) and the number of values entered. When the loop ends, print the smallest, the largest, the number of values,and the sum of values. Note that to keep the sum, you have to decide on a unit to use for that sum; use cm.

View 9 Replies View Related

C/C++ :: Calculate Result Of 2 Numbers That User Entered

Oct 29, 2012

In this exercise, write a rational number calculator that ask the user to enter two rational number:

a/b + c/d

and produce the result:

(ad+bc)/bd

View 10 Replies View Related

Visual C++ :: Creating Loop To Call In Entries From Text File Named Set

Jul 14, 2013

I am trying to create a loop to call in the entries from the text file named Set. The entries of Set.txtare :

1 2 3
2 4 5
and so on .. (64 such combinations)[/CODE]

It basically means the first combination for testing is 1 2 3 and next has to be 2 4 5 and so i have 64 such entries defined in set

My test files are located in D://data// and are named tst_data1 to tst_data64.

I created a loop for test set but its incorrect

Code:
// loop for test samples
char basefilename[] = "D://data//";
char , testFilen[160], numiChar[10];

for (int i=1; i<=64; i++) {
strcpy(basefilenme, "D://data//");
strcat(testfilename, Set[]);

[Code] .....

How can i call the Set .txt and how to define it.

View 1 Replies View Related

C :: Find The Largest And Smallest Number Entered By User?

Mar 6, 2015

How to find the largest and smallest number entered by a user. So far I'm able to add, find the average and count how many numbers are entered.

I'm just having trouble with find the max and min. I tried if statements and it breaks the program will it wont let me exit the while loop or the program will do a force close after entering a value.

Code:

#include <stdio.h>
#include <stdlib.h>
int main(){

int maxNum=0, minNum=0, value, count=0, sum=0;
double average;

[Code] ....

View 4 Replies View Related

C++ :: Find And Delete All Vowels In A Word That Is Entered By User

Mar 26, 2013

The program should find and delete all vowels in a word that is user entered. This is what I have so far and I know it should be essentially this format I just don't know how to set enteredword and word equal to each other.

#include <string>
#include <iostream>
using namespace std;
void vowelremover(string&);
int main () {
string word;

[Code] ....

View 3 Replies View Related

C++ :: How To Store Class Info Entered By User Into Array

May 7, 2013

So I have an array of my own class, "Restaurant," but I'm having a hard time figuring out how to store the info entered by the user into the array.

In total, I have two classes. I will show you all I have, it's a lot but I know it will be easier to understand.

My problem is in the AddRestaurant(), since that is where I should ask the user for all the information and store it in the array.

Also consider that I have to use the FTime class as well to handle the time. Basically I want to do something like this:

info[count].SetRating();

which will put the rating part of the class Restaurant into the array[count]

Also, my program doesn't compile because of the AddRestaurant and PrintAll functions since what I am showing is what I want to do, not what works.

//main.cpp
#include <iostream>
#include <iomanip>
#include <string>
#include "Restaurant.h"
#include "FTime.h"
int ReadMenuChoice();

[Code] .....

View 4 Replies View Related

C/C++ :: Calculate Percentage Of Even Numbers Entered By User In Array

Nov 18, 2014

exercise in c: write a program which calculates % of even numbers entered by a user in an array;

1) check if user hasn't entered float value; if has issue warning;
2) give the option for user to press "stop" to exit program any time.

int c,sk[100],i,sum1=0, sum2=0, rel;
printf ("How many numbers will you enter?
");
scanf ("%d", &c);
printf ("Enter %d numbers (to exit program press - stop)
", c);

[Code] ....

View 1 Replies View Related

C++ :: Cartesian Class - Display Coordinates Entered By User

Apr 6, 2014

I am trying to make a program with a Cartesian class that allows the user to enter 2 coordinates and displays these coordinates. When I try to compile it, I get a message saying the x and y in x=c and y=d don't name a type. How can I fix this? Also, how would I go about inserting an assignment function that assigns the values of coord1 to coord2?

Code:
#include <iostream>
#include <istream>
#include <ostream>
using namespace std;
class Cartesian {
private:
double x;
double y;

[Code] ....

View 9 Replies View Related

C++ :: Find Unequal Elements In Array Entered By User

Jan 12, 2014

I would like to know the algorithm or flow for finding unequal elements in an array entered by user. I tried using for loop but didn't get the expected output

Code:
#include <iostream>
#include <string>
using namespace std;
int main() {
int a[10],b[10]; //array of integer elements

[Code] ....

View 6 Replies View Related

Visual C++ :: Using Loop To Take User Input And Keep Running Sum Until 0 Entered

Feb 28, 2013

I am stuck on an exercise where i am supposed to use a loop to take user input and keep a running sum until the user enters a 0. the code i have so far is:

#include <iostream>
int main() {
using namespace std;
int num;
int total = 0;
int x;

[Code] ....

The full text of the error message is: error c2678:binary'>>':no operator found which takes a left-hand operand of type 'std::istream' . and one more thing i was wondering, is there a difference between c++ and visual c++?

View 4 Replies View Related







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