программирование c
i can see you, go out of here!
Mahdi Harzallah
i can see you, go out of here!
#include <stdio.h>
int main() {
printf("Hello, World!\n");
}
Dinosaurs love it!
#include <stdio.h>
#pragma warning (disable:4996)
struct address {
char city;
int cCode;
};
typedef struct {
char mem_name[25];
char mem_gender;
char mem_mail;
int mem_id;
int mem_ic;
int mem_num;
struct address addr;
} member;
int main() {
FILE* memptr;
member mem;
int x;
memptr = fopen("Member Info.bin", "wb");
if (!memptr) {
printf("Unable to open the file, please try again");
}
else {
printf("Enter your details: \n");
for (x = 0; x < 20; x++) {
printf("Name > ");
rewind(stdin);
scanf("%[^\n]", mem.mem_name);
printf("Gender (M = male, G = female) > ");
rewind(stdin);
scanf("%s", mem.mem_gender);
printf("Member ID > ");
rewind(stdin);
scanf("%d", mem.mem_id);
printf("NRIC (without -) > ");
rewind(stdin);
scanf("%d", mem.mem_ic);
printf("Contact Number > ");
rewind(stdin);
scanf("%d", mem.mem_num);
printf("Email > ");
rewind(stdin);
scanf("%[^\n]", mem.mem_mail);
printf("Address > ");
printf("\t\t City Name > ");
rewind(stdin);
scanf("%s", mem.addr);
printf("\t\t City Code > ");
rewind(stdin);
scanf("%d", mem.addr);
fwrite(&mem, sizeof(member), 1, memptr);
}
fclose(memptr);
}
memptr = fopen("Member Info.bin", "rb");
for (x = 0; x < 20; x++) {
fread(&mem, sizeof(member), 1, memptr);
printf("%s|%s|%d|%d|%d|%s|%s|%d\n", mem.mem_name, mem.mem_gender, mem.mem_id, mem.mem_ic, mem.mem_num, mem.mem_mail, mem.addr, mem.addr);
}
fclose(memptr);
}
C programming language is the mother language of all programming language.