C++ :: How To Add A Select Option
May 27, 2013
I just started on a project on c++ and I was wondering if it is possible to add a select option (where the c++ program requires the user to select an option) . I couldn't find this anywhere.
View 3 Replies
ADVERTISEMENT
Sep 9, 2012
I'm getting Unhandled exception when try to run option 3.
This my code below.
Code:
#include <iostream>
#include <string>
using namespace std;
struct Vet {
string name;
int numOfAnimals;
string phoneNum;
[code]....
View 8 Replies
View Related
Jul 30, 2013
I've been having problems with my loop that asks if the user wishes to continue or not. The required input should either be 'y' or 'Y', or 'n' or 'N'. Anything else should be counted as invalid, and repeat the prompt for input. The first few times I ran my program, the compiler does not read it as a loop. The next few times just won't work properly.
Here is the prompt:
Code:
void question() {
char option;
printf("
Do you want to continue? {Y|N) ");
scanf("%c", &option);
[Code] ......
As it is, it immediately runs the else option, but otherwise runs just fine. I suspect it could be because I have not specified a size for the option variable, but I try doing that, and the prompt relegates everything to the else.
(And also, here's the rest of the code. Basically, it just assigns a value to the letters of the word (a/A = 1, b/B = 2, etc.), adds these values, and determines if a word is prime or not based on the sum.)
Code:
#include <stdio.h>
#include <string.h>
#define size 30
int main() {
char letter, word[size], lower, upper, option;
int i, value, ans = 0, a, choice = 1;
[Code] .....
View 4 Replies
View Related
Feb 13, 2014
I have a menu for a project that takes a string input and does whatever option you specify. It works perfectly EXCEPT when it goes through the while-loop (while you didn't say quit the menu reloads). It will spew out all the text in the menu like a bulimic teenager. Then it reloads properly and asks you for an input like nothing happened. While this is not a fatal error (code still functions)...
Code:
#include <stdio.h>
#include <math.h>
#include <string.h>
double aa=0, ab=0, ac=0, sa=0, sb=0, sc=0;
char a1[13], o1[]="AAS
[Code] .....
View 2 Replies
View Related
Jan 14, 2014
i need one more option which it can display all the items i have entered in alphabetic order in my program..this is my coding......
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define capacity 1000
void cal_item(struct item[capacity]);
void input(struct item[capacity]);
}
[code]....
View 1 Replies
View Related
Apr 1, 2014
So , i had to make an rock paper scissors game . After lot of hard work and struggle ,I completed it but my professor rejected it since I didnot add option where it says "Would you like to play again .Y/N " . The code has too many brackets ! Here is my code
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
// for displaying the outputs to the user; passing string to functions
void user_win() {
[Code] ....
View 1 Replies
View Related
Nov 21, 2014
Remove the break statements from each of the cases. What is the effect on the execution of the program?
Add an additional switch statement that allows for a Passing option for a grade of D or better. Use the sample run given below to model your output.
Sample Run: What grade did you earn in Programming I ? A YOU PASSED! an A - excellent work!
Rewrite the program LastFirst_lab44.cpp using if and else if statements rather than a switch statement. Did you use a trailing else in your new version? If so, what did it correspond to in the original program with the switch statement?
// This program illustrates the use of the Switch statement.
// The break statement causes all subsequent expressions to be executed as well, also known as "falling through".
// The trailing else statement acts just like the default section if none of the options from before work it gets "defaulted" to it.
#include <iostream>
using namespace std;
int main() {
char grade;
cout << "What grade did you earn in Programming I ?" << endl;
[code]....
how do you add an additional switch statement? i tried multiple times and i'm not sure if i don't understand braces enough but it didnt seem doable. also, I'm not sure what the teacher wants me to submit.
View 1 Replies
View Related
May 6, 2014
I need to do a code that gave me Original string, uppercase string, lowercase string, reverse string (if letter is upper then convert to lower, and if lower then convert it to upper) and uppercase first (first character of each word in uppercase).
I need to do it in functions but i dont know hot to use strings. The program should provide the option to save the outputs in a file.
View 4 Replies
View Related
Apr 4, 2013
Code: Obj<TCHAR>* obj = dynamic_cast<Obj<TCHAR>* >(I->objects[0]);
Which is resulting in this error
Code: A dynamic cast is present, but the correct RTTI option is not specified.
View 3 Replies
View Related
Mar 11, 2013
I am running ubuntu and have tried adding -1GL to the end of my gcc compiling commands but the error says "unrecognized commandline option: 1GL". do i have to install any packages to get this to work?
Its supposed to be an l not a 1.
View 1 Replies
View Related
Sep 17, 2014
Basically i have a 'HomeWindow' with a button 'OptionWindow'. My idea is that the 'OptionWindow' button will open up the 'OptionWindow'. Which will give the user three options 'Option1', 'Option2' and 'Option3'. If they pick 'Option1' then in the 'HomeWindow' in a stackpanel i want it to display 'UserControl1'. Where as if they pick 'Option2' then in the 'HomeWindow' in a stackpanel i want it to display 'UserControl2'.
If you need some of my code that i have already then let me know what you need as i have a lot of it so can't paste it all in one go. But the new thing i need is the way of making the user-controls in the 'HomeWindow' change depending on what is selected in the 'OptionWindow'.
View 14 Replies
View Related
Aug 11, 2014
today I've been working on a rock, paper and scissors game. It compiles OK, except:
It doesn't use a random number from 1 -3, or goes out of scope.2. It doesn't COUT and it doesn't flush the buffer.3.
My code is as follows:
#include <windows.h>
#include <iostream>
#include <cstdlib>
#include <ctime>
std::string randomPC(int &);
void PCSelect(int &);
[code]....
View 2 Replies
View Related
Dec 13, 2014
I am asking if there is a way to select a file
View 8 Replies
View Related
Apr 7, 2014
I'm creating a program that is based on a menu system. Basically each menu is its own user-defined function. The problem is at each menu you can input 'b' to go to the previous menu. I just have it call the function of that menu.
However, do the functions need to complete themselves eventually? If I just keep calling functions will I just keep going further and further deeper into ever running functions?
If so how do I avoid this and yet keep the option to go back to a previous menu/function?
View 2 Replies
View Related
Dec 18, 2012
I understand including the comctrl32 lib and header. I know to init common controls. I can create a tab window and add tabs to it.
I just can't seem to grasp of how to tell when a specific tab has been selected. I just need to know what to look for with winproc.
View 2 Replies
View Related
Oct 1, 2013
I've a text file with 9 words and each word is written in a line. for exemple this is the list :
APPLE
ORANGE
MOON
CAR
CANDY
...
END
I'm gonna choose the fourth line and select the word that is in this line and work on. I tried lot of way but no result.
View 7 Replies
View Related
Jun 2, 2014
I am trying to write a program for a multiuser chat. I am trying to use select() function but I still cannot use the server for multiusers. I am able to access only one client at a time. I am running the code in Windows 7 using Visual Studio's Command Prompt. Here is the server code.
Code:
#include <stdio.h>
#include <winsock.h>
#include <stdlib.h>
#define WSVERS MAKEWORD(2,0)
WSADATA wsadata;
int main(int argc, char *argv[]) {
[Code] .....
View 3 Replies
View Related
Mar 13, 2015
I know that where I have the intIndex++ line is wrong. It's just going to stop at the last index and call it good, but I don't know how to make it stop at the matching name. The only examples I can ever seem to find use the foreach loop to print out a value, and I'm clearly just not understanding this enough to make it work for me.
Instructions are:
--Declare a variable to store the result of the search, int intIndex;
--Use an if statement with the Contains method to check if the name in the search box is in the queue.
--If Contains is true, initialize intIndex to zero and use a foreach to walk through queue, else display a message that the name is not in the list.
--If a match is found use intIndex to select the matching entry in listbox and display a message indicating the name was found. Be sure to increment intIndex each time through the loop.
private void btnSearchByName_Click(object sender, EventArgs e) {
//delcare int variable to use as the index for the list box
int intIndex;
//If Contains is true
if (cstrName.Contains(txtSearchName.Text))
[Code] .....
View 5 Replies
View Related
Mar 27, 2014
I am trying to select 3 questions randomly from a string array and create another array with the randomly selected questions then display them in labels.
As you can see in the code I have used Array.Clear method to remove the selected question from the array to prevent duplicate questions being selected. For some reason this is not working! The "Randomly" selected question is ALWAYS the 5th element [4] of the randomQuestions array and this element is duplicated for each iteration of the loop.
public void shuffleQuestions() {
string questionselected;
string[] randomQuestions = {
"What is the speed limit from the time you pass an Accident sign until you have passed the crash site?",
"What must you do at a red traffic light?",
"What is the maximum possible speed limit on the open road?",
[Code ....
View 12 Replies
View Related
Feb 10, 2015
this is my app interface as in attachment when i click an arrow it split the current selected window in arrow direction.
i want to know how to pass the current window to my button... i tried it using
Process[] processlist = Process.GetProcesses();
but it wont works
View 3 Replies
View Related
Sep 3, 2014
I have been working on my own custom web browser. If i insert a web browser in my tab control and name it i can easily just go webbrowser1.Navigate() in my button click to use the webbrowser methods.
I made a method CreateTab and it automatically adds a web browser to my tab along with a default web page.
My problem is selecting this webbrowser in other button clicks so i can call Home, Back, forward, etc.
Here is me method for creating a tab.
private void CreateTabItem()
{ //create a new tab
TabItem item = new TabItem();
item.Header = "Fitness" + i ;
WebBrowser browser = new WebBrowser();
//browser.Name = "Website";
[Code] ....
View 1 Replies
View Related
Mar 14, 2014
I'm having issues with selecting the next item in sequence in a combobox dropdown. The dropdown consists of letters A-Z and there is a timer that I have running to change the letter every x minutes. What I need to do is if, for example, letter A is selected, when the timer goes off, it will change to letter B, etc. If it's at letter Z, it needs to go back to the first item, letter A.
letterCode.SelectedIndex = letterCode.SelectedIndex + 1;
if (letterCode.SelectedIndex >= 26)
{
letterCode.SelectedIndex += 0;
}
I have the above, but I keep getting an error:
InvalidArgument=Value of '26' is not valid for 'SelectedIndex'.
how to get this working (letter changing logic block).
View 8 Replies
View Related
Mar 24, 2014
As requested by an exercise I have to write a function which:
- takes as parameter 1 unsigned which represent a timout value, 1 string which represent an IP address and an array containing port's numbers
- sends an UDP packet (1024 byte with NULL content) to each pair <IP,port>
- waits for the first reply, if it receives a packet within the timeout (set by select() function), the function returns the port of the process who replied, else it returns -1
I think I can do anything of above, but I've not understood how to set and use the select() in this case.
This is my code as it is at the moment
#define BUFLEN 1024
int comUDP ( unsigned timeout, char* ip, int ports[] ) {
int s_ds_sock, c_ds_sock;
struct sockaddr_in server_socket, client_socket;
char msg[BUFLEN] = NULL; //message to send to the clients
fd_set fds;
[Code] .....
View 2 Replies
View Related
Apr 22, 2013
I wanted to create an asynchronous/non-blocking udp client server application where the client and server were supposed to chat away with each other without waiting for each other's turns. I came to know that this could be done by select()... here is my Server(Mentioning only the communication part):
Code:
fd_set readfds,writefds;
while(1){
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_SET(sd,&readfds);
FD_SET(sd,&writefds);
int rv = select(n, &readfds, NULL, NULL, NULL);
[Code] .....
At first on the server side I wrote:
int rv = select(n, &readfds, &writefds, NULL, NULL);
But that led to the printing of an entire empty array on the server console when the server initialised in addition to the fact that communication between the server and client was not proper. removing "&writefds" did remove the redundant data but the improper communication issue still persists...
View 3 Replies
View Related
Dec 28, 2013
How do you randomly select a uniform value from a range of numbers?
View 1 Replies
View Related
Oct 8, 2014
Here is the whole code:
#include <iostream>
#include <ctime>
#include <cstdlib>
//This program prompts the user to select a number between 2 and 12
//computer throws two dices
//player win if selected number matches the sum of the two dices thrown by computer
[Code] .....
View 6 Replies
View Related