aboutsummaryrefslogtreecommitdiff
path: root/challenge-185/ulrich-rieke/cpp/ch-1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-185/ulrich-rieke/cpp/ch-1.cpp')
-rw-r--r--challenge-185/ulrich-rieke/cpp/ch-1.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-185/ulrich-rieke/cpp/ch-1.cpp b/challenge-185/ulrich-rieke/cpp/ch-1.cpp
new file mode 100644
index 0000000000..244b482591
--- /dev/null
+++ b/challenge-185/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,20 @@
+#include <iostream>
+#include <string>
+
+int main( ) {
+ std::cout << "Please enter a MAC address in the form hhhh.hhhh.hhhh!\n" ;
+ std::string address ;
+ std::getline( std::cin , address ) ;
+ int pos = 0 ;
+ std::string output ;
+ while ( pos < address.length( ) - 2 ) {
+ output.append( address.substr( pos , 2 )) ;
+ output.append( ":" ) ;
+ pos += 2 ;
+ if ( address.substr( pos , 1 ) == "." )
+ pos++ ;
+ }
+ //take the output substr because we want to leave out the final ':'
+ std::cout << output.substr(0 , output.length( ) - 1 ) << std::endl ;
+ return 0 ;
+}