Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as text by Artem ( 18 years ago )
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
void list(){
FILE *file=fopen("db.ini","r");
struct fuck{
char Name[9],NameLast[6],Gender[3],temp[10];
int BYear,LoS,Salary,id;
struct fuck *next;
};
struct fuck *beg, *tmp, *cur;
beg=NULL;
char buf[40];
while(fgets(buf,40,file)!=NULL){
tmp=(struct fuck *)malloc(sizeof(struct fuck));
for(int s=0;s<=8;s++){
if(buf[s]!=' '){
tmp->Name[s]=buf[s];
}else{
tmp->Name[s]='�';
break;
}
}
for(int s=9;s<=13;s++){
if(buf[s]!=' '){
tmp->NameLast[s-9]=buf[s];
}else{
tmp->NameLast[s-9]='�';
break;
}
}
for(int s=14;s<=17;s++){
if(buf[s]!=' '){
tmp->temp[s-14]=buf[s];
}else{
tmp->temp[s-14]='�';
break;
}
}
tmp->BYear=atoi(tmp->temp);
for(int s=19;s<=20;s++){
if(buf[s]!=' '){
tmp->Gender[s-19]=buf[s];
}else{
tmp->Gender[s-19]='�';
break;
}
}
for(int s=21;s<=23;s++){
if(buf[s]!=' '){
tmp->temp[s-21]=buf[s];
}else{
tmp->temp[s-21]='�';
break;
}
}
tmp->LoS=atoi(tmp->temp);
for(int s=24;s<=30;s++){
if(buf[s]!=' '){
tmp->temp[s-24]=buf[s];
}else{
tmp->temp[s-24]='�';
break;
}
}
tmp->Salary=atoi(tmp->temp);
tmp->next=NULL;
if(beg==NULL){
beg=tmp;
}else{
cur->next=tmp;
}
cur=tmp;
}
//====================SORT========================================================//
printf("!!!!!!%c!!!!!!n",cur ->next ->Name[0]);
//================================================================================//
for(cur=beg;cur!=NULL;cur=cur->next){
puts(cur->Name);
// puts(cur->NameLast);
// printf("%dn",cur->BYear);
// puts(cur->Gender);
// printf("%dn",cur->LoS);
// printf("%dn",cur->Salary);
}
}
void menu(){
system("cls");
int num=0;
puts("Please chose:n1 Listn2 Shown3 Exitn");
scanf_s("%d",&num);
if(num==1){
system("cls");
list();
_getch();
menu();
}if(num==2){
system("cls");
list();
_getch();
menu();
}if(num==3){
system("cls");
puts("Exiting...n");
}
}
int main()
{
menu();
return 0;
}
Revise this Paste