void float_eg() { int x = 3490593; float f = (float) x; printf("For x = %d\n", x); show_int(x); show_float(f); x = 3510593; f = (float) x; printf("For x = %d\n", x); show_int(x); show_float(f); }
int main() { int intVariable = 10; float floatVariable = 2.5f; int* intPointer = &intVariable; int intValue = *intPointer; short shortVariable = 10; long longVariable = 65535; double doubleVariable = 0.000125f; printf("int:"); show_int(intVariable); printf("float:"); show_float(floatVariable); printf("pointer:"); show_pointer(intPointer); printf("short:"); show_short(shortVariable); printf("long:"); show_long(longVariable); printf("double:"); show_double(doubleVariable); }
void test_show_bytes(int val){ int ival = val; float fval = (float) ival; int* pval = &ival; show_int(ival); show_float(fval); show_pointer(pval); }
int main(void) { int data = 0x12345678; float data_f = 0.12345; show_int(data); show_float(data_f); return 0; }
int main() { int i = 240; float f = 22.2; show_int(i); show_float(f); show_pointer(&f); return 0; }
void main() { int ival = 0x123456; float fval = (float) ival; int *pval = &ival; show_int(ival); show_float(fval); show_pointer(pval); }
int main(){ long int x; int y; float z; scanf( "%f",&z ); show_float( z ); scanf( "%d",&y ); show_int(y); return 0; }
int main(int argc, char *argv[]) { char carray[5] = {'a','b','c','d','e'}; int ix = 11111; float fx = -0.75; int idx; //validate the command line if( argc < 2 || !((strcasecmp(argv[1], "-all") == 0) || (strcasecmp(argv[1], "-char") == 0) || (strcasecmp(argv[1], "-int") == 0 ) || (strcasecmp(argv[1], "-fl") == 0 ))) { printf ("%s", "Invalid input: "); //display the command line input for (idx = 0; idx<argc; idx++) { printf ("argv[%d] = %s ", idx, argv[idx]); } printf ("\n"); printf ( "%s\n", "The input format: program -[all, char, int, fl] number\n"); } else { if (strcasecmp(argv[1], "-char") == 0) { print_format = PRINT_CHAR; printf("show_bytes...\n"); show_bytes(carray, 5); //show_pointer(carray); } if (strcasecmp(argv[1], "-int") == 0) { print_format = PRINT_INT; show_int(ix); show_pointer(&ix); } if (strcasecmp(argv[1], "-fl") == 0) { print_format = PRINT_FLOAT; show_float(fx); show_pointer(&fx); } } // printf("show_bytes...\n"); // show_bytes(carray, 5); // show_int(ix); // show_float(fx); }
int main() { int a = 10; float b = 11.5; double c = 13.33; void *d = &a; show_int(a); printf("\n"); show_float(b); printf("\n"); show_double(c); printf("\n"); show_pointer(d); getchar(); }
int main() { int val = 0x87654321; byte_pointer valp = (byte_pointer) &val; show_int(val); show_float((float) val); show_pointer(valp); show_bytes(valp, 1); show_bytes(valp, 2); show_bytes(valp, 3); return 0; }
int main(int argc, char *argv[]) { int i; unsigned uf; if (argc < 2) usage(argv[0]); for (i = 1; i < argc; i++) { char *sval = argv[i]; if (get_num_val(sval, &uf)) { show_float(uf); } else { printf("Invalid 32-bit number: '%s'\n", sval); usage(argv[0]); } } return 0; }
void test_show_bytes(int val) { int ival = val; float fval = (float) ival; int *pval = &ival; short sval = (short) ival; long lval = (long) ival; double dval = (double) ival; show_int(ival); show_float(fval); show_pointer(pval); show_short(sval); show_long(lval); show_double(dval); printf("\n"); }
int main(int argc, char *argv[]) { char carray[5]={'a', 'b', 'c', 'd', 'e'}; int ix = 11111; float fx = 1.5; int idx; if (argc == 1 ) { printf ( "help info: %s\n", "the input format is"); } else { for (idx = 0; idx<argc; idx++) { printf ("argv[%d] = %s ", idx, argv[idx]); } if (strcasecmp(argv[1], "-c") == 0) { print_format = PRINT_CHAR; printf("argv show_bytes...\n"); show_bytes(carray, 5); } if (strcasecmp(argv[1], "-i") == 0) { print_format = PRINT_INT; show_int(ix); } if (strcasecmp(argv[1], "-f") == 0) { print_format = PRINT_FLOAT; show_float(fx); } } // printf("show_bytes...\n"); // show_bytes(carray, 5); // show_int(ix); // show_float(fx); }
int main(){ show_int(3510593); show_float(3510593.0); }