473,386 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to take IPV6 input in c++ need help

Hi!
i'm really not a programming guy but one of teacher asked me to use c++ and take input of ipv6 address from user and then perform following:
1. convert the address to binary
2. write it in a short form

any help is appreciated.. thank you in advance
Jul 1 '15 #1
2 1603
weaknessforcats
9,208 Expert Mod 8TB
So ignore the ipv6 stuff and write a program where the user enters an address, like 1234567. If you accept that into an unsigned int, then it is already in binary.

Do you know if the teacher meant the user typed the address in hexadecimal? Like A6B5C4D3? Then you would need to convert the hex to binary.

There is an if/then/else syntax in C++ and various techie types prefer a "short form", which is using the ternary operator from 1968 C. That would be the (condition)?do-this-if-true : do this-if-false rather than coding if/else. My suggestion here is to use if/else to get things working and then replace the if/else with the ternary operator ?:
Jul 1 '15 #2
donbock
2,426 Expert 2GB
It can help to "storyboard" your program before trying to write it.

For example, consider a program that takes a user entry and converts it first to one thing and then to another. Make a table with three columns on a pad of paper, where the first column is the user entry and the remaining columns are for the two outputs. Fill out the table for a few reasonable inputs; but then add entries for odd inputs (empty string, illegal characters, out of range value, minimum value, maximum value, etc).

I find that visualizing the necessary conversions makes writing the code easier.

This pen-and-paper storyboard (or table) is essentially a statement of the requirements for the program. You can't write a program if you're unsure what it is supposed to do.
Jul 1 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roel | last post by:
Hello, I have a simple script that will reload http://website/CAM1picture.jpg every xx minutes. I'm trying to add a form <input type="submit" value="CAM1" name="B1"><input type="submit"...
2
by: cm500 | last post by:
I'm very new to databases so bear with me. What I need is a way to track the training for the employees at my firm. I have 40 classes that I will be teaching on various subjects and various...
16
by: negrito | last post by:
I need help to create this program: This program will take user input in the folowing order: 1.number of tickets sold. 2.percentage of ticket revenue which goes to administrative costs.This input...
1
by: Benton2862 | last post by:
I need help with and array for a program that acts like a cash register. The user will input an items price and then there payment. It will tell you the change and then tell you what kinda of change...
1
by: basestring | last post by:
Hi, I need help for my program. I'm new With PHP but i have programming skills in VB so it's quit easy to understand this language, however. i got my self in some problems that i don't understand....
3
by: dalearyous | last post by:
ok basically i need to write a program that will replace normal words in a sentence with pirate words. the trick is it needs to be able to take two word phrases. i went about this two different ways:...
1
by: Dansmith122 | last post by:
Hi I have been working on the java script for my website and I need help with the out put variables. I need to know how to add more variable for each row in my survey. I am very lost ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.