It's a question about code c

Asked 2 years ago, Updated 2 years ago, 31 views

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main() {
    char* *szdata;
    int count = 0, maxlenth = 0;
    scanf("%d*c", &count);
    szdata = (char**)malloc(sizeof(char*)*count);
    scanf("%d*c", &maxlenth);

    for (int i = 0; i < count; i++) {
        szdata[i] = (char*)malloc(sizeof(char) * (maxlenth + 1));

        printf ("input");

        scanf("%s", szdata[i]);


    }
    for (int i = 0; i < count; i++) {
        puts(szdata[i]);

    }

}

If you change the printf in the first for statement to gets_s, the input is omitted once, so why is that? ㅜ<

code

2022-09-21 13:54

1 Answers

printf is the output function, and get_s is the input function. I don't know if you have putts_s, but try it with that function


2022-09-21 13:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.