Results 1 to 4 of 4
Thread: C
Hybrid View
-
25th December 2012 12:59 #1Registered 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()
-
25th December 2012 14:58 #2
, 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.
-
25th December 2012 16:02 #3Registered User
Join Date: Aug:2008
Location: &
Posts: 136
for- , , "" , . - :
, :Code:for(i=strlen(name);i=='\0';i--);
for. :Code:for(i=strlen(name);name[i]=='\0';i--);
, ,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 . .
-
25th December 2012 22:55 #4




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in