Results 1 to 4 of 4

Thread: C

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Aug:2008
    Location: &
    Posts: 136

    C

    : , .c ( ). , .
    , . , gets(). for . 13 , 10 , (.c) '\0'. , , 14 + 2 1 NULL= 16, 13. 15 , .d, - .


    :
    Code:
    void TextInput() {
    
        FILE *in, *out;
        int c,i;
        char name[13]={'\0'};
        printf("\nChoose a name for your .c file: ");
           gets(name);
    		for(i=strlen(name);i=='\0';i--);
    		name[i]='.';
    		i++;
    		name[i]='c';
    		i++;
    		name[i]='\0';
    		printf("\n");
    		printf("The file %s was successfully created!",(name));
    		fflush(stdin);
    
        in=stdin;
        out=fopen((name),"w");
        if(fopen==NULL) {
            printf("\nCannot write to file:");
        exit(1);
        }
        else
            printf("\nType the program code in the .c file\n\n");
        {
            do {
                c=fgetc(in);
                if(feof(in))
                    break;
                fputc(c,out);
    
            } while(c!=EOF);
    
            fclose(out);
        }
    }//end of TextInput()

  2. #2
    System.gc()'s Avatar
    Join Date: Apr:2007
    Location: back in time
    Posts: 1,075
    , 12 . , , for/if, , , C/C++.
    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.

  3. #3
    Registered User
    Join Date: Aug:2008
    Location: &
    Posts: 136
    for- , , "" , . - :
    Code:
    for(i=strlen(name);i=='\0';i--);
    , :
    Code:
    for(i=strlen(name);name[i]=='\0';i--);
    for. :
    Code:
    printf("\nChoose a name for your .c file: ");
    	gets(name);
    	i=strlen(name);
    	name[i]='.';
    	i++;
    	name[i]='c';
    	i++;
    	name[i]='\0';
    	printf("\n");
    	printf("The file %s was successfully created!",(name));
    	fflush(stdin);
    , , , for- . , . , , -, 100 . .

  4. #4
    System.gc()'s Avatar
    Join Date: Apr:2007
    Location: back in time
    Posts: 1,075
    C, gets, , deprecated, , . , .
    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 |