C++ :: Prompt User To Enter Domain Name - Return Resolved IP Address
Feb 16, 2013
This is a winsock program designed to prompt the user to enter a domain name. The program is then supposed to return to the user a resolved ip address of that domain name. The user should also be able to enter an IP address and receive back a domain name.
While the program prompts the user to enter the domain name, all that is ever returned is error#:0
HTML Code:
// Declare and initialize variables
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#include <windows.h>
#pragma comment(lib, "ws2_32.lib")
#include <iostream>
int main(int argc, char **argv) {
hostent* remoteHost;
I am simply trying to prompt a user to enter M for Male or F for Female. However, when I test run the program (what I've got so far below), any letter inputted is accepted and continues the program..?
#include <iostream> using namespace std; int main() { char gender; int maleBodyWeight;
I'm expected to write a c program for this question :
Using these header files #include <stdio.h> #include <conio.h>
Question : Write a program that will prompt the user to enter an integer value and a character code to indicate whether they want to do a Kilogram to Pounds conversion (A) or a Pounds to Kilogram (B) conversion. Note that 1 kg = 2.2 pounds. The program should then do the necessary conversion indicated by the code and display the newly converted value to the screen.
I'm having a problem with the two while statements in my UDF.
- 1. It will run both while loops twice...?
- 2. It now goes into a continuous loop.
- 3. When it did work, it would only return 1 value to the main()...?
#include <iostream> // for use of "cin" & "cout", endl... #include <iomanip> // for formatting setw function #include <cmath> // for the general math computations #include <string> // for creating descriptive strings #include <sstream> // used to convert a string to an integer //user defined function int userValue (int);
I'd like a function to return either a value or the address of that value by the users input. So he can call the function like:
function("adress") - gets an adress, or function("value") - gets the value
I've tried both function overloading and templates, but none of them worked. He might input a character for the address and an int for the value... but...
Another strange thing that i observed is that the value returned by the function below is 0, so the output is address 0.
You can return values from functions by ref, address or value you can also do this with parameters, so what is the difference, if you have full return of a passed parameter by ref or address why would you need to ever return the function as a whole?
For ex Code: int nValue(int& y){ y++; } or int& nVlaue(int y){ return y; }
The Question : Complete the following function that takes 2 integers m and n as parameters. The function defines a dynamic matrix of integers of size mXn, fills the matrix with information from the KB, then returns the address of the matrix.
Note: DO NOT forget to put the returned datatype in the given space(………….) ………………………. allocate (int m, int n) { }
My solution :
int allocate (int m, int n){ cin>>n>>m; int **a; a=new int *a[n]; for (int i =0; i<n; i++) a[i] = new int[m]; for (int i=0; i<n ; i++) for (int J=0; j<m ; j++) cin >> a[i][j]; }
Here is a simple drinks machine programm. It basically consists in the user selecting a drink that it's presented, if the user selects correctly the number representing a certain drink, the machine shows the user what was the drink he selected, after his choise the machine asks for money insertion, if the user inserts the incorrect amount of money, the machine shows an error saying that user need to insert the correct amount of money.
My problem is that, if the user selects a different number other than those presentend, the machine displays an error saying that he needs to choose a valid drink, but i can't find a way to reprompt the user again after the error has been displayed. here's the code.
// ***Drinkins Machine*** by Roxmate #include <iostream> #include <cstdlib> using namespace std; int main() { // initializes the variables coca, fanta, iced and drink to be used in switch function,so that the user can choose what drink he wants. int coca = 1;
Currently I have to manually look up values on several different tables in different locations. I have 8 or 10 tables with 100 to 500 parts.
I would like to write a program so if I enter a value it will return the corresponding correct answers from the tables.
If I entered 2.5 for a value it would return the following three items from the tables since they all meet the requirement.
Table 2 Part min max 235 2.4 2.9
Table 6 Part min max 589 2.3 2.5
Table 7 Part min max 12 2.3 2.7
What would the best method be for setting up and accessing tables like this? Is C++ good at representing something like this or should I be looking at a different language?
I am trying to write a program to get user's input but only accepts alphabetic characters, nothing else and I want it to ask the user to enter a valid word until they have finally entered a valid one. I have the following code for it but it does not work properly.
void CheckBound (char word1[], int SIZE1) { int i; int w1[SIZE4]= {0}; int found; for (i=0;i<strlen(word1);i++) {
#include <iostream> #include <limits> int getInt() { int x = 0; while(!(cin >> x))
[Code] ....
But this function prompts the user to only input integer values. I was thinking if I could maybe try tweaking with this one so that the user could only enter letters..no luck though. So how can I have the user input letters only?
Try to implement overloading << operator. If I done it void then everything work fine (see comment out) if I make it class of ostream& then the operator return to me some memory address.
Code: #ifndef Point_HPP // anti multiply including gates #define Point_HPP #include <sstream> class Point { private:// declaration of private data members double x;// X coordinate double y;// Y coordinate
how to re-prompt a user with a switch statement menu that I prompted them earlier with. There are 4 options and after the user chooses an option the menu is supposed to pop up again unless the user chooses option 4, how do I do this? For reference I'll put up my source code.
Code: int main(){ int init_bal,choice,balance,investment, donation; printf("Welcome!
i need to prompt the user of my program to input numbers into an array so that later on these numbers can be added or subtracted with other numbers to form a new array. My problem is I don't know how to make the user input numbers which will then be saved into the array for later use. Here is the parts of my code that relate to the problem:
Code:
float Xv, Yv, Zv, Xu, Yu, Zu ; float vector1[VECTOR_LENGTH] = {Xv, Yv, Zv} ; scanf("%1f %1f %1f", &Xv, &Yv, &Zv); printf("The first element in the array vector1 is: %3f ", vector1[0]);
The point of that printf function is to see if what they have entered is actually registering as what i want it to. This does not work however and the value for this always comes up as 0.
how to scan numbers into an array so that they can be used for later use?
I need to create a program that will prompt the user for an input, then it will save their input to a file and then it will prompt the user to input "Open" and then the file containing their first input, will open up and show their input.
I'm trying to develop a programme which, amongst other things, prompts the user to enter the filename which is to be opened. This is what my code looks like currently:
char filename[20]; FILE *myfile;
printf("Enter the full file name you would like to open:"); scanf("%s", filename);
[Code] .....
However, this only ever returns File Not Found - the file is stored in the same directory as the program, and I have tried looking up this issue online, to no avail ....
I am having problems printing "->" on the beginning of each line, im trying to do it as a loop and ending it when the user types "q". also i would like to know how to ignore text from the user when the input begings with a specific character. heres what ive done so far, and not currrently working as expected.
Code: #include <stdio.h> int main (void) { char prompt; printf("~~~ FRACTION CALCULATOR ~~~
Design an algorithm using flowchart or pseudo-code to prompt the user for a series of positive integer values. Calculate the average of these values and display the average at the end of the program. Assume that the user types the sentinel value -1 to indicate end of data entry.
Sample input-output: Enter a positive integer (-1 to end) : 5 Enter a positive integer (-1 to end) : 7 Enter a positive integer (-1 to end) : 6 Enter a positive integer (-1 to end) : -1
The average value is: 6
I searched online and found out this solution however it is only for three numbers.Is there any way of modifying this to include the sum of x numbers / number of x(integers) to find the average?