I am using a loop to delete characters from a string using printf(\b) 1 by 1 and sleep 0.1 seconds in between. But when I run the code it happens simultaneously.
I literally tried typing each printf because I thought the loop might be the cause but still, the output was the same
#include <stdio.h>
#include <unistd.h>
void coolIntro(){
int i;
printf("A Game by Hideo Kojima");
Sleep(800);
for(i=0;i<12;i++){
printf("\b");
Sleep(100);
}
printf("my_name_here");
}
Run Code Online (Sandbox Code Playgroud)
I want the letters to disappear with …
我是一名新的数据结构学生,并试图熟悉 c 结构。我从我过去的 python 经验中知道继承,所以我想在 c 中进行伪尝试。我的代码是这样的:
typedef struct{
char name[20];
int age;
int weight;
int selling_price;
} Animal;
typedef struct{
Animal *animal;
int can_speak;
}super_animal;
int main() {
Animal monkey;
strcpy(monkey.name,"Mustafa");
monkey.age=19;
monkey.weight=80;
super_animal human;
human.animal=&monkey;
human.can_speak=1;
printf("%s, can speak bool:%d\n",human.animal->name,human.can_speak);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我想从代码中删除中间的猴子步骤。是否可以使用这样的未分配结构指针?