Skip to content
Check out how to use the Networking functions!

Networking

Dec To Hex Examples*

Simple Decimal to Hexadecimal Converter

The following code shows examples of using dec to hex to convert a decimal value to a hex value.

#include "splashkit.h"
int main()
{
write_line("Hello! Welcome to the decimal to hexadecimal converter.");
// Prompt the user for a decimal input
write_line("Please enter a decimal number:");
// Read the input as a string
string dec_input = read_line();
// Convert the input string to an unsigned integer
unsigned int dec_value = convert_to_integer(dec_input);
// Convert the decimal value to hexadecimal format
string hex_value = dec_to_hex(dec_value);
// Display the result in hexadecimal format
write_line("The decimal value in hexadecimal format is: " + hex_value);
return 0;
}

Output:

dec_to_hex-1-converter example


Hex To Dec String Examples*

Simple Hexadecimal to Decimal String Converter

The following code shows examples of using hex to dec string to convert a hex value into a decimal string.

#include "splashkit.h"
int main()
{
write_line("Hello! Welcome to the hexadecimal to decimal converter.");
// Prompt the user for a hexadecimal input
write_line("Please enter a hexadecimal number:");
// Read the input as a string
string hex_input = read_line();
// Convert the hexadecimal string to a decimal string
string dec_value = hex_to_dec_string(hex_input);
// Display the result in decimal format
write_line("The hexadecimal value in decimal format is: " + dec_value);
return 0;
}

Output:

hex_to_dec_string-1-converter example


Ipv4 To Dec Examples*

Simple IPv4 To Decimal Converter

The following code shows examples of using IPv4 to Dec to convert an IP address into decimal form.

#include "splashkit.h"
int main()
{
write_line("Hello! Welcome to the IP to decimal converter.");
// Prompt the user for an IP input in dotted decimal format (e.g., 127.0.0.1)
write_line("Please enter an IPv4 address in dotted decimal format (e.g., 127.0.0.1):");
// Read the input as a string
string ip_input = read_line();
// Convert the IPv4 string to a decimal
unsigned int ip_as_dec = ipv4_to_dec(ip_input);
// Display the result
write_line("The IP address in decimal format is: " + std::to_string(ip_as_dec));
return 0;
}

Output:

ipv4_to_dec-1-converter example


Ipv4 To Hex Examples*

Simple IPv4 To Hex Converter

The following code shows examples of using IPv4 to Hex to convert an IP address into hex form.

#include "splashkit.h"
int main()
{
write_line("Hello! Welcome to the IP to hexadecimal converter.");
// Prompt the user for an IP input in dotted decimal format (e.g., 127.0.0.1)
write_line("Please enter an IPv4 address in dotted decimal format (e.g., 127.0.0.1):");
// Read the input as a string
string ip_input = read_line();
// Convert the IPv4 string to hexadecimal format
string ip_as_hex = ipv4_to_hex(ip_input);
// Display the result in hexadecimal format
write_line("The IP address in hexadecimal format is: " + ip_as_hex);
return 0;
}

Output:

ipv4_to_hex-1-converter example