Results 1 to 4 of 4

Thread:

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User froid's Avatar
    Join Date: Oct:2006
    Location:
    Posts: 97

    Red face

    . :

    FA FB, ( notepad) . FA FB TABA TABB . TABA TABB TABC . , TABC FC, . TABA, TABB TABC, , .

    , . :

    Code:
    #include<stdio.h>
    #include <stdlib.h>
    
    int *lire(char *nom_fichier,int *n);
    void print(int *a,int n);
    void depl_lire(int *a,int n,char *nouveau_fichier);
    
    
    void main(void)
    {    int n, i, *a;
         char nom_fichier[10], nouveau_fichier[10];
         printf("Vuvedete imeto na purviq fail: ") ;
         scanf("%s", &nom_fichier);
         a=lire(nom_fichier,&n);
         printf("\nSudurjanieto na failut e:\n");
         printf("\n");
         print(a,n);
         printf("\n Vevedete imeto na vtoriq fail: ") ;
         scanf("%s", &nom_fichier);
         a=lire(nom_fichier,&n);
         printf("\nSudurjanieto na failut e:\n");
         printf("\n");
         print(a,n);
         printf("\nVuvedete imeto na noviq fal: ");
         scanf("%s", &nouveau_fichier);
         depl_lire(a,n,nouveau_fichier);
    
    }
    
    int* lire(char *nom_fichier,int *c)
    {    FILE *p;
         int x, i,*tab, *t;
         *c=0;
         p=fopen(nom_fichier,"r");
         if(p==NULL)
    	{ printf("Failut ne e otvoren!\n",nom_fichier); exit(1); }
         fscanf(p,"%d",&x);
         while(!feof(p))
    	{     (*c)++;
    	      fscanf(p,"%d",&x);
    	}
         tab=(int *)malloc(*c*sizeof(int));
         if(tab==NULL)
    	{ printf("Problem\n"); exit(1); }
         t=tab;
         rewind(p);
         *c=0;
         fscanf(p,"%d",tab);
         while(!feof(p))
    	{    (*c)++;
    	     fscanf(p,"%d",++tab);
    	}
         fclose (p);
         return t;
    }
    
    void print(int *a,int n)
    	{  int i;
    	   for(i=0;i<n;i++,a++)
    		printf("%3d",*a);
    	   printf("\n");
    	}
    
    void depl_lire(int *a, int n, char *nouveau_fichier)
         {  int i,temp;
            FILE *nf;
        nf=fopen(nouveau_fichier,"w+");
            if(nf==NULL)
    	{ printf("Failut %s ne e otvoren!\n",nouveau_fichier); exit(1); }
    
        for(i=0;i<n;i++,a++)
        fprintf(nf,"%d\n",*a);
    	fseek(nf,0,0);
    	fscanf(nf,"%d",&temp);
    	while(!feof(nf))
    	   {  printf("%d",temp);
    	      fscanf(nf,"%d",&temp);
    	   }
    	fclose(nf);
         }
    lire tab. , ?

  2. #2
    Registered User
    Join Date: Aug:2008
    Location: Varna
    Posts: 291
    . ... .
    int* lire( const char *filename, size_t /* out */ *count );

  3. #3
    Registered User
    Join Date: Oct:2003
    Location:
    Posts: 4,317
    Quote Originally Posted by froid View Post
    ......
    lire tab. , ?
    , ?

  4. #4
    Registered User froid's Avatar
    Join Date: Oct:2006
    Location:
    Posts: 97
    , .

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 |