#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
#if 0
char buf[256];
printf("Enter a value\n");
fgets(buf, 256, stdin);
printf("You input value to float %f, to int %d, to long %ld, to long long %lld\n", atof(buf), atoi(buf), atol(buf), atoll(buf));
#endif
#if 0
char strbuf[256];
char* strend;
printf("Enter string value list\n");
fgets(strbuf, 256, stdin);
printf("You inpu value to float %f \n", strtof(strbuf, &strend));
printf("Nest value is %f\n", strtof(strend, NULL));
#endif
#if 0
// Generate secret number between 1 and 10
srand(time(NULL));
int ran = rand() % 10 +1;
printf("Rand value is %d \n", ran);
#endif
#if 0
char* path;
path = getenv("PATH");
if (NULL != path)
printf("Current path is %s \n", path);
#endif
#if 0
printf("Abs funciton of 32 is %d, -10 is %d\n", abs(32), abs(-10));
#endif
#if 0
div_t divResult;
divResult = div(35, 6);
printf("Div funciton 35/7 result %d, remainder %d\n", divResult.quot, divResult.rem);
#endif
#if 1
printf("Please input string length you what\n");
char strbuf[256];
fgets(strbuf, 256, stdin);
char* memAlloc = (char*)malloc(atoi(strbuf));
memAlloc = "erichao";
printf("Mem context is %s\n", memAlloc);
#endif
system("pause");
return 0;
}
<cstdlib> stdlib.h头文件
于 2022-01-21 19:37:02 首次发布