online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
//#![allow(unused)] #![deny(unused)] /* How do I print in Rust the type of a variable? https://stackoverflow.com/questions/21747136/how-do-i-print-in-rust-the-type-of-a-variable */ /* Function:- type_of<T> */ fn type_of<T>(_: T) -> &'static str { let variable_type:&'static str; variable_type = std::any::type_name::<T>(); return variable_type; } /* Function:- print_type_of<T> */ fn print_type_of<T>(_: T) { println! ( "{}" , std::any::type_name::<T>() ); } /* Function:- print_type_of_variable_unused<T> */ fn print_type_of_variable_unused<T>(var: T) { println! ( "{}" , std::any::type_name::<T>() ); } /* Function:- main */ fn main() { /* Declare Variables */ let number_integer:i32 = 10; let number_float:f32 = 45f32; let variable_type:&str; /* Get Type of Variable */ variable_type = type_of(number_integer); println!("{0}", variable_type); /* Invoke Function print_type_of */ print_type_of(number_float); /* Invoke Function print_type_of_variable_unused */ print_type_of_variable_unused(variable_type); }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue