C/C++ :: Make Multi Cout / Cin In The Same Line?

Nov 17, 2014

#include<iostream.h>
#include<conio.h>
main()

[Code]....

I tried to make the output look like this --> ENTER YOUR NAME:Victor Collin ENTER YOUR COURSE:BSComSci
but everytime I entered my name the course went to the next line.How to make the output in the same?

View 7 Replies


ADVERTISEMENT

C :: How Can A Multi-line String Be Read Line By Line

Mar 7, 2014

How can a mulitline string be read line by line

ex: str = "PERIOD="week"
DAY="day"
TIME="time"";

View 2 Replies View Related

C++ :: How To Make Minimax Multi Player

Nov 29, 2013

I have pseudo code for the minimax algorithm but i was wondering what i would need to add to make it work with many players (n players)?

score minimax(state s, int n)
if (n = 0 OR s is a terminal node) {
if win position for program
return +inf;
if loss position for prg

[Code] ....

View 3 Replies View Related

C++ :: Multi Data Types In A Line And Read To Struct?

Aug 14, 2014

How can I read this file in to my struct?

12345Joe Lim KH879.00
12233Kay Suet Yee35.98
23781Leong Jing Yang 10.00
67543Woon Tian Yi500.50
struct master {
unsigned short int IDnum;

[code]....

not working

View 16 Replies View Related

C++ :: Can Use Templates To Make A Multi-type Linked List?

Apr 28, 2014

If I wanted an int connected to a float connected to a string connected to a POD, would all I have to do is :

Code:

template<class T, class X>
struct node {
T data;
node<X> *next;
};

Or would I be forced into using polymorphism?

View 10 Replies View Related

C :: Make Fgets Stop Reading When It Reaches A New Line?

Apr 13, 2014

How can I make fgets stop reading when it reaches a new line? Right now it will read the new line and continue until the buffer is full. I was thinking something like this.

Code:
while(fp!='
'){
fgets(password, 256, fp);
}

View 2 Replies View Related

C++ :: Program To Make Shopping List - One Line Per Entry

Jan 9, 2015

OK I'm making a simple program to make a shopping list. I would like the program at start up to load the previous shopping list that was saved as a text file. The format is one line per entry which consists of the category or Isle, and the item description. Here's an example:

3 Dog Food
Produce Sweet Onions

I reading the first word, and then I want to read the rest of the line which may have more than one word... the problem is my code hangs... or goes into the old infinite loop. It doesn't see the end of file.

Here is my code:

void
addItemsFromFile(vector<item> &shoppingListVector) {
string word;
char buf[30];
if (fileExists("shoppinglist.txt"))

[Code] .....

View 3 Replies View Related

C :: Make Array Stop Reading From Input When It Hits A New Line?

Nov 25, 2013

I want the numbers to be put into the array until it hits a new line. Maximum number of numbers is 1000. What can I replace that while loop with to stop it from reading further into the input file?

Code:

while (input != '
'){
for(i=0; i<1000; i++)
fscanf(ifp, "%lf", &auctions_prices[i]);

View 2 Replies View Related

C++ :: Make Object Coordinates Moving In Straight Line With Angle Have A Sinus?

Sep 22, 2013

I want to make an object, which moves from x1,y1 to x2,y2 in a straight line, also make a sinus over the line (so the x,0 is the line itself, and cux,cury is the object. So the object will move as a sinus over the line. How do I do this in c++?

View 3 Replies View Related

C/C++ :: Trying To Cout Vector

Jun 10, 2014

This is what my code looks like

class Transaction{
private:
char type;
double amount;
double balance;
string description;

[Code] .....

This part is what I am having trouble with as this section is not printing anything.

for (int i = 0; i < transactions.size(); i++){
cout << transactions[i].gettype() << " ";
cout << transactions[i].getamount() << " ";
cout << transactions[i].getbalance() << " ";
cout << transactions[i].getdescription() << " ";
}
}

View 2 Replies View Related

C++ :: Difference Between Cout And Cerr

Oct 30, 2013

Other than the theoretical difference between cout and cerr where the former puts values to the monitor and the latter puts values related to errors to the monitor, is there any real difference here? Why not use cout when you want to send anything to monitor? Why use cerr at all?

View 7 Replies View Related

C++ :: Double Values On Cout

Mar 6, 2014

Here is code first:

//fp_screen.h
class fp_screen{
public:
double fps;
double xx3;

[Code] .....

fps:1.16922e+006 // this will happen 80%
fps:900 // this is how it should be

if i do cout << "fps:" << (int)screen.fps << endl;

Somethings number is right like 800 or else
put sometimes its 5423423... something.

What is going on here?

View 5 Replies View Related

C++ :: Cout Not Displayed After While Loop

Sep 7, 2014

Am having a problem with the following program not displaying the cout after the while loop, it doesn't ask if I want to enter another employee but just prompts for the employee payrate again.

#include <iostream>
using namespace std;
int main()
// Parameters: None
// Returns: Zero
// Calls: None

[Code] ....

View 1 Replies View Related

C/C++ :: How To Cout The String Characters Themselves

May 11, 2014

Iam working with arrays and i cant get to the write solution to cout the characters.

the Question is : Write a program that inputs a character string from the user as an input (using cin.get())and store it in myStr[ ] array.Assume that the length of the input string is less than 100 characters and the string may contain lower case, upper case, and/or symbols.The program should then print the number of lower case, upper case, digits, and symbols along with the characters themselves.

my code :

#include <iostream>
#include <string>
#include<iomanip>
using namespace std;
int main() {
int ctr1=0, ctr2=0, i=0, ctr3=0;

[Code] ...

What i have now, how can i cout the uppercase characters and the lower case characters and the symbol characters !

View 3 Replies View Related

C++ :: Need Cout To Print Function Output?

Nov 16, 2013

Finally got to functions. Made a simple one that adds two numbers:

Code: int add(int a, int b){
cout<<"a+b=";
return a+b;
}

It refuses to give an output unless I use cout.

If I just call the function like so: "add(12, 24);", shouldn't it print out a+b=36? It only prints out "a+b=", unless I use "cout<<" ahead of the call.

My simple question is why does it need cout ahead of the call? Shouldn't "return" do its job and print out the number?

View 2 Replies View Related

C++ :: Cout And Cin Objects Of Iostream Class

Feb 17, 2013

i ran the following code in the latest version of code::blocks and it tells me that the objects cout and cin are not declared in this scope. what is the problem?

I used to use Turbo C++ 3.0 and i had no problem whatsoever with that compiler. But now i am trying to move to code::blocks but it is proving very very hard as all the standards have been changed.

I am a school student and thus, we had been told to practice on Turbo C++ 3.0 and now i am unable to unlearn it. Also, if i use printf in place of cout there is no error but i want to use cout as it is what i am comfortable working with.

#include<fstream>
#include<conio.h>
int main() {
using namespace std;
char name[20];

[Code] ....

Is there some document to which i can refer so as to get the latest C++ standards which is C++0x i believe?

View 7 Replies View Related

C++ :: Cout Double Or Float Without Additional 0?

Jun 30, 2013

I m working calculating stuff in files, input and output data, etc..., the question is the following: I output double numbers with:

myFIle << fixed << setprecision(10) << double;

The problem i got is that when a numer is like 193123.2 it prints like 193123.200000..., so finally, ¿how can i print it with any additional 0 that i need?.

View 1 Replies View Related

C++ :: New Project Doesn't Cout Any Values?

Apr 11, 2014

I'm trying to build a new project and i installed some new libraries in it but when i try to compile any code it doesn't give me any value just press any key to continue, i didn't make any files but one and even if i tried to do this simple task it doesn't cout any result:

#include<iostream>
using namespace std;
int main() {
cout <<("ha");
system("pause");
return 0;
}

View 4 Replies View Related

C++ :: Cout Total Element In Array

Feb 28, 2013

I am beginner in C++ programming. I having a problem to show the output of all the element i store at a array called total_price. the output become unreadable.

#include <iostream>
using namespace std;
int main () {
float price[1]={0};
int qty;

[Code] ....

View 6 Replies View Related

C++ ::  How To Cout Boolean Result In Words

Dec 11, 2013

So I want to go from having 0 or 1 to having words like false or true. I did it with an if statement earlier today, but I had to get rid of the whole bool thing. I made the variable just a float. But he requires we use bool. Here is my code:

Car y;
cout << "Initial value for the Car: " << endl;
cout << "Age= " << y.getAge() << " years old. The Price= $" << y.getPrice() << endl;
y.setAge(8);
y.setPrice(12000);
y.setRaceCarStatus(true);
cout << "Modified value for the Car: " << endl;

[Code]...

I commented (//) the if statement that I had earlier. If I set RacecarStatus to True, is cout's 1. The starred (*) line right above the comments is the line that I was required to add. I want to cout the actual word true. The one I had this morning won't work anymore.

View 1 Replies View Related

C++ :: Infinite Cout Loop In Else Statement?

Dec 12, 2014

I have more programming before this, but everything else works fine. My else loop has an infinite output. i also want it to output an error message if the value is not an integer and return to the input

cout << "Select number corresponding material for fencing:" << endl;
cout << "wood = 1" << endl;
cout << "stone = 2" << endl;
cout << "aluminium = 3" << endl;
cin >> material;
if (material == 2){
cost = 100 * perimeter;

[code]....

View 7 Replies View Related

Visual C++ :: Cout Is Not Displaying Text?

Apr 13, 2013

I'm making a very first program. It's very little more then a simplistic calculator, but i'm having a problem with the cout function. It won't display any text what could the reasons be?

#include <iostream>
#include <string>
#include <sstream>
using namespacestd;
int main () {
do {
int(a);

[Code]...

Oh and i'm aware it's still riddled with numerous problems, I just have been working on the cout thing first.

View 3 Replies View Related

C++ :: How To Convert Write Procedure To Cout

Aug 18, 2013

I'm building a Console class(i realy need it). and i don't understand how can i build the Write() procedure. Heres the structure:

write(varname1[,varnamex])

how can i convert it to cout?

View 14 Replies View Related

C++ :: Error With Cout - No Operator Matches Operands

Nov 11, 2013

Getting error: no operator "<<" matches these operands at line 36.

#include "stdafx.h"
#include <string>
#include <iostream>
#include <ostream>
using namespace std;
struct Date {

[Code] ....

View 8 Replies View Related

C++ :: Printing Out A Cout Statement Using Stored Variables

Feb 9, 2015

Im trying to run my program and it works fine until the very end where I want it to read "<name> is a <gender> citizen of <nation>." with the corresponding variables. Here is my work for the time being. Also is there a way to make it where if someone puts a M or m for gender, it will spit out Male instead of just m or M.

#include <iostream>
using namespace std;
int main()
{
char gender;

[Code].....

View 2 Replies View Related

C++ :: Creating Poem - Cout Overwriting Data

Mar 20, 2012

So in a nutshell I have to write a program that grabs a random line from a file and exchange the numbers for words from other files to create a poem. The problem I have is that when I go to output the parts of the ntca it gets all jumbled and writes over each other. (See output below)

I saw something about a memory leak, but I couldn't see how that could be happening in this program. It's a basic intro level program for a class and I'm just a little stuck.

Code:

void create_poem(const int poem_lines) // called from main function {
//Peform each for each line
for(int x = 1; x <= poem_lines; x++) {
char begin_line[1000];

[Code] ....

Everything works perfectly except for the output which looks like this :

Code:
A 2 2 1 and 1 3 1 // <-- this is the line before translation
junkcarrnet

As stated, I know everything else works through debugging purposes. Just the overwriting is my only problem.

View 1 Replies View Related







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