it skips the input phase,, instead of inputting the last name it goes directly to the firstname then middle initail and street name are working fine but it skips the street name then goes to city and so on....
Code:
char l[50], f[50], m;char strtname[50], cty[50], cntry[50];
int strtnum, zp, i;
system("cls");
printf("Enter Last name:");
gets(l);
printf("
Enter First name:");
}
I am altering this program to include some alterations for a class. When I run it with start without debugging, it just skips to press any key to continue. It will not display the cout << "Volume of box1 = " <<boxVolume1.
#include "stdafx.h" #include <iostream> using std::cout; using std::endl; class CBox { public: double m_Length; double m_Width;
I am so close to finishing this program of games, but I'm running into some issues while debugging it.
I've attached the google drive folder since there are several files (ignore the ones with [conflict], etc)...
First, I have the main menu using a switch to select the game. The default was set to exit. If initially when immediately opening the program you put in for say, a letter, it would exit like its supposed to. But if you went and played any of the games ], went back to the main screen, and entered a letter then, it would crash. I've put in a testing line to make sure that you enter a number, and not anything else.
Now however, if you play a game and then want to go back to the main menu, it will simply skip over waiting for your response and close the program. The same thing happens in the slot machine, I want to have it spin the slot machine by pressing enter, but it simply skips over the input, and I'm not sure why.
I just recently finished up a program that implements Dijkstra's Algorithm and I thought I would make a nice little menu for the user.
so the user can input their locations, I use Getline just in case their location contains spaces. However, when the user selects 2, It skips over the first input for the "Source" location and only lets the user input for the "Destination".
Any reason why this would happen? Am I missing something with Getline? Anyway, here's the code...
I have to write this program that is to store the name, address, id number, etc of a student. The data is supposed to be brought in through main and there will be multiple students. I'm not sure what commands I should use to bring it in.
EDIT: This will make more sense. In the .txt file the info will be written like
Name Last name Address etc.
I need to input that and use that for the appropriate number of students.
So I have a two-dimensional array named temperatures[7][2] and I am trying to promt the user to input the highest temperatures for a 7 day period in the first column and the lowest temperatures in the second column. So far all I am getting when I test my code is the temperatures in the second column.
/*Intermediate23.cpp - This program inputs the highest and lowest temps. for seven days. It then displays the average high and low temps. and also diplays the highest temp. that's stored in the first column of the array and displays the lowest temp. stored in the second column of the array.*/
#include <iostream> #include <iomanip> using namespace std; int main() { //Declare array and variable int temperatures[7][2] = {0}; int avg = 0; int totalTemp = 0;
The app just blocks. Could it be due to a lack of RAM (since its inside a massive loop and I'm currently using an old-ass pc with 1GB RAM) or is it bad programming? If I remove that line everything runs smoothly.
I am doing a data structures program on C++ that is suposse to consist of declaring an array of size five for my credit card structure, that allows the user to input information of five diferent credit cards. I am having a problem with my program, because it runs but after I input the information of the credit card, it does not print out the values that I had input.I dont know where I went wrong with the code or if it is that my approach to solving it is wrong. My code is the following:
using namespace std; const int SIZE = 40; const int COLUMN = 5; void getData(ifstream& inf, string n[], double tstData[][COLUMN], int count);
[Code] .....
when I compile and run the code and have it display it does not read the first item into the 1-d array, instead it appears to read the 4th number from the left into the 1-d array and then into the second spot in the 2-d array, then again in its proper place and finally it has this number repeating through the rest of the arrays:
-92559631349317830000000000000000000000000000000000000000000.00 followed by the number 59.7 from the .txt and the long number again.
here's one more thing id like to do to make the input even better able to handle user error, but im not sure if its possible or at least easy. I need the function to return a large positive number. As of right now, it can handle users entering characters, but what if the user enters a negative number? is there a way to check to see if what is coming in is negative before the sign gets lost in conversion to unsigned"ness"?
Code: unsigned long getNum(char prompt[80]) { unsigned long darts; printf("%s", prompt); while((scanf("%lu", &darts)) != 1) { [code]....
I am a beginner trying to write a program that would state a user's chinese zodiac and horoscope sign after inputing his or her birthday. I have been, however, having trouble getting the program to run correctly.
error C2440: 'initializing' : cannot convert from 'void' to 'std::basic_ifstream<_Elem,_Traits>' 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits<char> 1> ] 1> Expressions of type void cannot be converted to other types
Code: #include <stdio.h> int main(){ int A, B; char decision; printf("Do you have an integer to input? [Y/N]: "); scanf("%c",&decision); if(decision=='Y' || decision=='y'){
[Code]....
After entering a single integer, it doesn't scan again for another integer. What's wrong?
I'm using a mac btw, if that makes a difference with Ubuntu/Linux.
I have learnt recently how to use fgetc, fputc, fputs, fgets but still I am not able to figure out how to read values from a file like for example:
12 14 1928 32993932 17 98 166 109 201
These are separate integers & i want to read them and then manipulate these individual integers like going for 2*I1, 4*I2 and so on where I1 and I2 are 12 & 14.
I want to have calculations take place inside a switch statement that calls the appropriate function. The menu portion of the program works well, but I can't figure out how to let the user actually input 2 different numbers to the functions. My questions are:
1. If I use scanf to assign values to the variables, what determines end of input to each variable? (ie.. scanf("%d%d", &a, &b) what is the end of a, what is the end of b?)
2. Should I assign the variables to user input inside the switch, or try to do it in the functions below?
3. Is there something I haven't thought to ask that will screw me over? I'm really new to this.
Code: #include<stdio.h> int add(int b, int a); int mult(int b, int a); main() {
[Code] ....
This really was a test of multilayer menu, but I want to add functionality if I can.
Changed a variable before posting and didn't change all the conditions testing it.
On my program I use a counter to count to 10, then i ask for a string, in this case "yes" or "no", during the count, i want to keep the user from putting inputs in, due to the fact that if they put both "yes" and "no" before the program reads the string.
I have a project that requires I take user input from menu options and put it into an array which I will average out. I can set the menu up I think, but I cannot understand how to put what the user inputs into an array. Granted I just took the lecture on arrays today. Also we can only use functions to do the work.
I don't know how many numbers will be the input only that its going to be up to 10000. EOF should be active. I tried it like this:
Code:
int i = 0; int del[10000] while (scanf("%d",del[i])!=EOF) { i++; }
But it seems the value of i doesn't increment, could you provide some tips on how to scanf the inputs into an array if I don't know how many numbers will I have?
For a program I am required to use a cin that accepts 4 variables. The first describes a function such as add(), remove(), print(), or quit(). The problem is that to use add() I need to input all 4 variables but for remove(), only 2 variable input is needed.
I want the input to be "add 9 James Bond" or be "remove 341"
Here is my current code.
int command(string command, int Id, string first, string last){ while (command != "quit"){ cout << "customers> "; cin >> command >> Id >> first >> last; if (command == "add")