C_template

jason8826發表於2024-04-18
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    char input[1000] = {0};
    char *temp = NULL;
    int nums[100] = {0};
    int lengh = 0;

    
    if (NULL == fgets(input, 1000, stdin))
    {
        printf("fgets error\n");
        return 1;
    }
    
    temp = strtok(input, " ");
    while (NULL != temp)
    {
        nums[lengh++] = atoi(temp);
        temp = strtok(NULL, " ");
    }

    for (int i = 0; i < lengh; i++)
    {
        printf("%d ", nums[i]);
    }

    return 0;
}