Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- version (D_LP64) {
- alias ulong size_t;
- } else {
- alias uint size_t;
- }
- extern (C) void* malloc(size_t);
- extern (C) void* realloc(void*, size_t);
- extern (C) int printf(char* s, ...);
- extern (C) char* gets(char* s);
- extern (C) size_t strlen(char* s);
- extern (C) int atoi(char* s);
- int main()
- {
- printf("Hello.\n");
- printf("I am curious, what is your name? ");
- char* name = cast(char*) malloc(1024);
- char* agestr = cast(char*) malloc(1024);
- gets(name);
- while (strlen(name) == 0) {
- printf("Please, don't be shy. What is your name? ");
- gets(name);
- }
- printf("So. Your name is '%s'? That's an interesting name...\n", name);
- printf("Tell me, '%s', how old are you? ", name);
- gets(agestr);
- while (strlen(agestr) == 0) {
- printf("Come now, how old? ");
- gets(agestr);
- }
- int age = atoi(agestr);
- if (18 > age) {
- printf("Wonderful! Please, come in to my study.\n");
- } else {
- printf("Hmph. Is that the time? Must go...\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment