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;
[Code] ....
View 12 Replies
ADVERTISEMENT
Dec 24, 2014
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;
[Code] .....
View 2 Replies
View Related
Sep 14, 2013
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.
View 1 Replies
View Related
Aug 5, 2014
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);
[code].....
View 1 Replies
View Related
Oct 9, 2012
How can I do this??
Suppose I have Win2008server and many users from defferent domains log in, so every user has its own session.
How can I obtain from the session the domain name of the user who logged in to server??
View 1 Replies
View Related
Feb 1, 2015
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.
class testing
{
public:
static int x;
[Code].....
View 2 Replies
View Related
Feb 5, 2014
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;
}
View 1 Replies
View Related
Mar 19, 2013
How can i returns the address of the matrix.
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];
}
View 2 Replies
View Related
Nov 29, 2014
Can I return a non-dynamic local address of a var from a function?
int* func(int m){
m=1;
return m;
}
My compiler giving warning but compiles and returns add but My tutor handout says it will not compile...!!! she used array in func and returned arr[m]
View 4 Replies
View Related
Mar 9, 2013
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;
[code]....
View 5 Replies
View Related
Dec 17, 2013
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?
View 3 Replies
View Related
Dec 3, 2014
prompts a User for all elements of a 3x3 matrix. Your program should then print the matrix as well as the transpose of the matrix
View 1 Replies
View Related
May 12, 2014
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++) {
[Code] .....
View 2 Replies
View Related
Mar 1, 2013
How do I have the user enter only letters?
#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?
View 3 Replies
View Related
Jul 26, 2012
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
[Code] .....
View 7 Replies
View Related
Mar 6, 2015
I'm trying to write this c++ programe:
Write a password prompt that gives a user only a certain number of password entry attempts, so that the user cannot easily write a password cracker.
Using FOR Loop. I know this can be easily done using while loop. But I want to know how to do it with for loop aswell.
Here is what I have so far:
Code:
#include <iostream>
#include <string>
using namespace std;
int main ()
[Code] ....
I don't see where the problem is.. The program just executes and does nothing.
View 9 Replies
View Related
Sep 20, 2013
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!
[Code]....
View 2 Replies
View Related
May 17, 2013
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?
View 9 Replies
View Related
Dec 28, 2014
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.
View 19 Replies
View Related
Aug 31, 2014
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 ....
View 2 Replies
View Related
Mar 17, 2013
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 ~~~
[Code] ....
View 1 Replies
View Related
Nov 18, 2013
Write a program that asks the user to prompt an Integer number and then test whether it is Palindrome Numbers or not.
The following are Palindrome numbers:
1.22
2.333
3.67876
4.44444
5.123454321
View 8 Replies
View Related
Nov 24, 2014
I have trouble printing out the movies starting with inputing only two letters.
#include <iostream> //cout, cin, endl,getline
#include <fstream> //ifstream
#include <cstdlib> // exit
using namespace std;
const int NUM_MOVIES = 116792;
struct Movie {
[Code] ....
View 1 Replies
View Related
Apr 7, 2013
Is it possible to prompt information from user then display the result in a one dimensional array form? If yes, how should i link them together?
View 7 Replies
View Related
Apr 19, 2013
I have a list of objects that I need to read information from each object to compare to a user input prompt.
#include "Passenger.h"
#include "Reservation.h"
#include "Aircraft.h"
#include <iostream>
#include <fstream>
#include <string>
#include <list>
using namespace std;
//Function Prototypes
void flightRoster(list<Reservation>&);
[Code] ....
View 1 Replies
View Related
Oct 26, 2014
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?
View 5 Replies
View Related