LINUX.ORG.RU

История изменений

Исправление Dron, (текущая версия) :

dron@gnu:~$ cat del.c 
#include <stdio.h>
#include <assert.h>
#define MAXLEN 100500 /*Новые угарные серии на KарамбаTV ::)*/
int main(void)
{
    const char my_file[]="/home/dron/test.txt";
    int buff;
    char str[MAXLEN];

    FILE * stream=fopen(my_file,"r");
    assert(stream);

    for (int i = 0; (buff=fgetc(stream))!=EOF && i<MAXLEN; i++)
    {
        str[i]=buff;
    }

    for (int i = 0; str[i] != '\0'; )
    {
        buff=str[i];
        i++;
        for(int x=i; str[x]!='\0';x++)
        {
            if(buff == str[x])
            str[x]=EOF;
        }
    }


    for (int z = 0;str[z] != '\0' ; z++)
    {
        if(str[z] != EOF)
        printf("%c",str[z]);
    }

    return 0;
}
dron@gnu:~$ gcc -std=c99 del.c ; ./a.out 
asfdjhgner
dron@gnu:~$ 

Исходная версия Dron, :

dron@gnu:~$ cat del.c 
#include <stdio.h>
#include <assert.h>
#define MAXLEN 100500 /*Новые угарные серии на KарамбаTV ::)*/
int main(void)
{
    const char my_file[]="/home/dron/test.txt";
    int buff;
    char str[MAXLEN];

    FILE * stream=fopen(my_file,"r");
    assert(stream);

    for (int i = 0; (buff=fgetc(stream))!=EOF; i++)
    {
        str[i]=buff;
    }

    for (int i = 0; str[i] != '\0'; )
    {
        buff=str[i];
        i++;
        for(int x=i; str[x]!='\0';x++)
        {
            if(buff == str[x])
            str[x]=EOF;
        }
    }


    for (int z = 0;str[z] != '\0' ; z++)
    {
        if(str[z] != EOF)
        printf("%c",str[z]);
    }

    return 0;
}
dron@gnu:~$ gcc -std=c99 del.c ; ./a.out 
asfdjhgner
dron@gnu:~$