Skip to content

Commit

Permalink
upload 4.11
Browse files Browse the repository at this point in the history
  • Loading branch information
TGSpock123 committed Apr 11, 2024
1 parent 8e15c76 commit 416f263
Show file tree
Hide file tree
Showing 264 changed files with 3,331 additions and 4,926 deletions.
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .vs/CMakeWorkspaceSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enableCMake": true
}
Binary file modified .vs/cmake.db
Binary file not shown.
12 changes: 12 additions & 0 deletions .vs/launch.vs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "C_primer.exe",
"name": "C_primer.exe"
}
]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1,016 changes: 1,016 additions & 0 deletions .vs/learn_c_primer.github.io/config/applicationhost.config

Large diffs are not rendered by default.

Binary file removed .vs/learn_c_primer.github.io/v16/.suo
Binary file not shown.
Binary file removed .vs/learn_c_primer.github.io/v16/Browse.VC.db
Binary file not shown.
Binary file removed .vs/learn_c_primer.github.io/v16/Browse.VC.db-shm
Binary file not shown.
Binary file not shown.
Binary file modified .vs/learn_c_primer.github.io/v17/.wsuo
Binary file not shown.
Binary file modified .vs/learn_c_primer.github.io/v17/Browse.VC.db
Binary file not shown.
222 changes: 175 additions & 47 deletions .vs/learn_c_primer.github.io/v17/DocumentLayout.json

Large diffs are not rendered by default.

Binary file modified .vs/learn_c_primer.github.io/v17/Solution.VC.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/learn_c_primer.github.io/v17/workspaceFileList.bin
Binary file not shown.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
10 changes: 0 additions & 10 deletions .vs/tasks.vs.json

This file was deleted.

4 changes: 3 additions & 1 deletion 1/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <stdio.h>

int main() {
int main(void)
{
printf("Hello, World!\n");

return 0;
}
Binary file added 13/.test1321.un~
Binary file not shown.
Binary file added 13/.testtest.txt.un~
Binary file not shown.
2 changes: 1 addition & 1 deletion 13/13.1.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ int main (int argc, char * argv[])
{
int ch;
FILE * fp;
unsigned long count =0;
unsigned long count = 0;

if (argc != 2)
{
Expand Down
38 changes: 38 additions & 0 deletions 13/13.1.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char * argv[])
{
int ch;
FILE * fp;
unsigned long count =0;

if (argc != 2)
{
printf ("usage: %s filename\n", argv[0]);
exit (EXIT_FAILURE);
}
else;

if (!(fp = fopen(argv[1], "r")))
{
printf ("can't open %s\n", argv[1]);
exit (EXIT_FAILURE);
}
else;

while ((ch = getc(fp)) != EOF)
{
putc (ch, stdout);
count ++;
}

if (fclose(fp))
{
printf("error in closing file %s\n", argv[1]);
}
else;

printf ("file %s has %lu characters\n", argv[1], count);

return 0;
}
18 changes: 18 additions & 0 deletions 13/13.10.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE* fp;
int k;

fp = fopen("test1310", "w+");

for (k = 0; k < 30; k++)
{
fputs("Nanette eats geldtin. \n", fp);
}

fclose(fp);

return 0;
}
Binary file added 13/13.10.exe
Binary file not shown.
45 changes: 45 additions & 0 deletions 13/13.11.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
FILE* fp;
double ret = 0, num;
int cot = 0;

if (argc == 2)
{
if ((fp = fopen(argv[1], "r")) == NULL)
{
printf("wrong in opening %s. \n", argv[1]);
exit(EXIT_FAILURE);
}
}
else if (argc == 1)
{
fp = stdin;
printf("please enter numbers, q to quit: \n");
}
else
{
printf("fullstop. \n");
exit(EXIT_FAILURE);
}

while (fscanf(fp, "%lf", &num) == 1)
{
ret += num;
cot++;
}

if (cot != 0)
{
ret /= cot;
printf("%lf\n", ret);
}
else
{
printf("No numbers read.\n");
}

fclose(fp);
return 0;
}
Binary file added 13/13.11.exe
Binary file not shown.
76 changes: 76 additions & 0 deletions 13/13.12.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[])
{
char ch, buf[256];
FILE* fp1;

if (argc < 3)
{
printf("handle failure. \n");
exit(EXIT_FAILURE);
}
else;

if ((fp1 = fopen(argv[2], "r")) == NULL)
{
printf("open %s failure. \n", argv[2]);
exit(EXIT_FAILURE);
}
else;

ch = argv[1][0];
setvbuf(fp1, buf, _IOLBF, sizeof(buf));

while (fgets(buf, 256, fp1))
{
for (int i = 0; buf[i] != '\0'; i ++)
{
if (buf[i] == ch)
{
fputs(buf, stdout);
break;
}
}
}

fclose(fp1);
return 0;
}

/*
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
char ch, buf[256];
FILE* fp1;
if (argc < 3) {
printf("Usage: %s filename character\n", argv[0]);
exit(EXIT_FAILURE);
}
fp1 = fopen(argv[2], "r");
if (fp1 == NULL) {
printf("Failed to open %s\n", argv[1]);
exit(EXIT_FAILURE);
}
ch = argv[1][0];
setvbuf(fp1, buf, _IOLBF, sizeof(buf));
while (fgets(buf, sizeof(buf), fp1)) {
for (int i = 0; buf[i] != '\n'; i++) {
if (buf[i] == ch) {
fputs(buf, stdout);
break;
}
}
}
fclose(fp1);
return 0;
}
*/
Binary file added 13/13.12.exe
Binary file not shown.
35 changes: 35 additions & 0 deletions 13/13.13.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int ch;
FILE * fp;
unsigned long count = 0;
char str[50];

printf ("please enter file's name: \n");
scanf ("%s", str);

if (!(fp = fopen(str, "r")))
{
printf ("can't open %s\n", str);
exit (EXIT_FAILURE);
}
else;

while ((ch = getc(fp)) != EOF)
{
putc (ch, stdout);
count ++;
}

if (fclose(fp))
{
printf ("error in closing file %s\n", str);
}
else;

printf ("file %s has %lu characters\n", str, count);

return 0;
}
Binary file added 13/13.13.exe
Binary file not shown.
30 changes: 30 additions & 0 deletions 13/13.14.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char * argv[])
{
FILE * fp1, * fp2;

if (argc != 3)
{
printf ("negative enter. \n");
exit (EXIT_FAILURE);
}else;

if ((fp1 = fopen (argv[1], "r")) == NULL)
{
printf("error opening %s. \n", argv[1]);
exit(EXIT_FAILURE);
}else;

if ((fp2 = fopen (argv[2], "w")) == NULL)
{
printf("error opening %s. \n", argv[2]);
exit(EXIT_FAILURE);
}else;

for (char ch; (ch = getc(fp1)) != EOF; putc(ch, fp2));

fclose (fp1);
fclose (fp2);
return 0;
}
Binary file added 13/13.14.exe
Binary file not shown.
32 changes: 32 additions & 0 deletions 13/13.15.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
int main (void)
{
FILE * fp1, * fp2;
char f_name_1[50], f_name_2[50];

printf ("this program turns lower into upper. \n");
printf ("please enter the first file name: \n");
scanf ("%s", f_name_1);
printf ("now enter the second file name: \n");
scanf ("%s", f_name_2);

if ((fp1 = fopen (f_name_1, "r")) == NULL)
{
printf("error opening %s. \n", f_name_1);
exit(EXIT_FAILURE);
}else;

if ((fp2 = fopen (f_name_2, "w")) == NULL)
{
printf("error opening %s. \n", f_name_2);
exit(EXIT_FAILURE);
}else;

for (char ch; (ch = getc (fp1)) != EOF; islower (ch) ? putc (toupper (ch), fp2): putc (ch, fp2));

fclose (fp1);
fclose (fp2);
return 0;
}
Binary file added 13/13.15.exe
Binary file not shown.
Loading

0 comments on commit 416f263

Please sign in to comment.