#include<stdio.h>
int main()
{
        char *arg[10],*c;
        int count=0;
        FILE *fp,*fq;
        printf("Name of the file:");
        scanf("%s",arg[1]);
        fp=fopen(arg[1],"w");
        printf("\t\t%s",arg[1]);
        printf("Input the text into the file\n");
        printf("Press Ctrl+d to the stop\n");
        while((*c=getchar())!=EOF)
        {
                fwrite(c,sizeof(char),1,fp);
                count++;
        }
        return 0;
}

Where do your pointers point?

You never allocate any space for the char pointer arg[1] . You could either call a function like malloc and dynamicly allocate space for that c-string, or you could declare the c-string to the stack, like char arg1[100]; .

May be you may compare your code with this one:

#include<stdio.h>
int main()
{
        char arg[50];
        int c;
        int count=0;
        FILE *fp;
        printf("Name of the file:");
        scanf("%s",arg);
        fp=fopen(arg,"wt");
        printf("\t\t%s",arg);
        printf("Input the text into the file\n");
        printf("Press Ctrl+Z and Return on windows to the stop\n");
        while((c=getchar())!=EOF)
        {
                fputc(c, fp);
                count++;
        }
        fclose(fp);
        return 0; 
}

You will note some important diferences.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.