Results 1 to 2 of 2

Thread: C[++?]

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Sep:2008
    Location: /
    Posts: 42

    C[++?]

    . : C , :
    -- ;
    -- ;
    -- ;
    -- ;
    ( , - )
    :
    -- ;
    -- ;
    -- , , ;
    , ( ) , .. ? :
    Code:
    #include <stdio.h>
    #include <iostream>
    #include <stdlib.h>
    #include <string.h>
    struct uch {
           char ime[100];
           int kl;
           char uc[100];
           int toch;
           char nom[100];
           } st;
           int i;
           char s[30];
           FILE *myfile;
           int susht(char *s) {
                FILE *file;
                file=fopen("datafile","r");
                fclose(file);
                return file!=NULL;
                }
           void write(uch *st) {
                printf(":\n"); gets(st->ime);
                printf(":\n"); gets(st->uc);
                printf(":\n"); gets(st->nom);
                int de=atoi(st->nom);
                if(de==0) { 
                printf("   ''\n"); 
                return;
                }
                printf(":\n"); scanf("%d",&st->kl);  
                if(st->kl>12 || st->kl<1) { printf("   ''\n"); return;}
                printf(":\n"); scanf("%d",&st->toch);
                getchar();
                } 
           void read(uch st) {
                printf(": %s\n",st.ime);
                printf(": %s\n",st.uc);
                printf(": %s\n",st.nom);
                printf(": %d\n",st.kl);
                printf(": %d\n",st.toch);
                }
           void file() {
                char e;
                if(susht("datafile")) { printf(" .   ?(N  )\n"); printf("\a   \n"); e=getchar();
                if (e=='n') return; }
                myfile=fopen("datafile","wb");
                fclose(myfile);
                system("CLS");
                printf("  \n");
                system("pause"); }
           void dobavi() {
                char e;
                if(!susht("datafile")) {
                printf("   \n"); return; }
                myfile=fopen("datafile","a+b");
                do {
                write(&st);
                fwrite(&st,sizeof(st),1,myfile);
                printf("    ?(N  )\n");
                e=getchar(); 
                getchar();
                } while (e!='n');
                fclose(myfile);
                }
           void iztrii() {
                FILE *txt;
                char nom1[100];
                int k;
                if(!susht("datafile")) { printf("   \n"); return; }
                myfile=fopen("datafile","rb");
                k=0;
                fread(&st,sizeof(st),1,myfile);
                while (!feof(myfile)) {
                k++; 
                read(st);
                fread(&st,sizeof(st),1,myfile);
                }
                fclose(myfile);
                if (k==0) { printf("  \n"); return; }
                printf("     :\n"); gets(nom1);
                myfile=fopen("datafile","rb");
                txt=fopen("txtfile","wb");
                fread(&st,sizeof(st),1,myfile);
                while (!feof(myfile)) {
                if (strcmp(st.nom,nom1)!=0) { fwrite(&st,sizeof(st),1,txt); }
                else { system("CLS"); printf("       %s\n",nom1); }
                fread(&st,sizeof(st),1,myfile);
                }
                fclose(myfile);
                fclose(txt);
                remove("datafile"); rename("txtfile","datafile");
                }
     /*      void spis() {
                int k;
                myfile=fopen("datafile","rb");
                k=0;
                fread(&st,sizeof(st),1,myfile);
                while (!feof(myfile)) {
                k++; 
                read(st);
                fread(&st,sizeof(st),1,myfile);
                }
                fclose(myfile);
                }*/
                                                              
           int main() {
                int k,i;
                uch st;
                system("chcp 1251");
                do {
                printf(" \n");
                printf(" \n");
                printf("1 --    \n");
                printf("2 --    \n");
                printf("3 --   a  \n");
                printf("4 --    10   \n");
                printf("0 -- \n"); 
                scanf("%d",&k);
                getchar();
                switch(k) {
                case 1: file();break;
                case 2: dobavi();break;
                case 3: iztrii();break;
               // case 4: spis();break;
                }
                } while(k!=0);
                return 0;
                }
    .
    Last edited by Skygod; 11th May 2011 at 09:16.

  2. #2
    System.gc()'s Avatar
    Join Date: Apr:2007
    Location: back in time
    Posts: 1,075
    , [CODE] , - ?
    UD3R|Q9550+1283|4x2 G.Skill@1066|MX500+1002FAEX+640AAKS+ST31 60|RX580-8GB|1841BLT|SS-760XP|Define7|z24i|Edifier S350DB
    geniusloci: ) ; ) ; ) ? nope|r.i.p.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |