#include <stdio.h>
#include <string.h>
#include <stdlib.h> // For malloc

#define SLEN 20

struct User {
    char *id;
    int *age;
};

int main() {
    struct User user1;
    char temp[SLEN];

    // Get ID from user
    printf("Enter id: \n");
    fgets(temp, SLEN, stdin);
    temp[strcspn(temp, "\n")] = 0; // Remove newline character if present
    user1.id = (char *)malloc(strlen(temp) + 1);
    strcpy(user1.id, temp);

    // Get age from user
    printf("Enter age: \n");
    int intTemp;
    scanf("%d", &intTemp); // Use scanf to read an integer
    user1.age = (int *)malloc(sizeof(int)); //don't need +1
    *user1.age = intTemp;

    printf("id: %s, age: %d\n", user1.id, *user1.age);

    // Free allocated memory
    free(user1.id);
    free(user1.age);

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: