小编Mus*_*nar的帖子

How can i use printf("\b") to make my console output look like typewriter?

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 printf console-output backspace

2
推荐指数
1
解决办法
53
查看次数

是否可以在 C 中没有另一个初始化结构的情况下从结构继承

我是一名新的数据结构学生,并试图熟悉 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)

我想从代码中删除中间的猴子步骤。是否可以使用这样的未分配结构指针?

c oop inheritance pointers structure

1
推荐指数
1
解决办法
32
查看次数

标签 统计

c ×2

backspace ×1

console-output ×1

inheritance ×1

oop ×1

pointers ×1

printf ×1

structure ×1