Skip to content

Commit 155f549

Browse files
committed
Merge branch 'main' into jquery
2 parents d97d219 + 915dc44 commit 155f549

File tree

7 files changed

+1266
-156
lines changed

7 files changed

+1266
-156
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ RUN apk add --no-cache nginx && mkdir -p /run/nginx
1111
COPY --from=build /usr/share/nginx/html/ /usr/share/nginx/html/
1212
COPY --from=build /etc/nginx/nginx.conf /etc/nginx/nginx.conf
1313
EXPOSE 80
14-
CMD ["nginx", "-g", "daemon off;"]
14+
HEALTHCHECK --interval=1s --timeout=3s CMD wget -q -O - http://localhost:80 || exit 1
15+
CMD ["nginx", "-g", "daemon off;"]

source/_posts/c.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const int BIRTHYEAR = 1980;
7878

7979
```c
8080
// this is a comment
81-
printf("Hello World!"); // Can comment anywhere in file
81+
printf("Hello World!\n"); // Can comment anywhere in file
8282

8383
/*Multi-line comment, print Hello World!
8484
to the screen, it's awesome */
@@ -87,12 +87,12 @@ to the screen, it's awesome */
8787
### Print text
8888
8989
```c
90-
printf("I am learning C.");
90+
printf("I am learning C.\n");
9191
int testInteger = 5;
92-
printf("Number = %d", testInteger);
92+
printf("Number = %d\n", testInteger);
9393
9494
float f = 5.99; // floating point number
95-
printf("Value = %f", f);
95+
printf("Value = %f\n", f);
9696
9797
short a = 0b1010110; // binary number
9898
int b = 02713; // octal number
@@ -183,7 +183,7 @@ printf("%s", greetings);
183183
```
184184
185185
**NOTE**: String literals might be stored in read-only section of memory. Modifying a string literal invokes undefined
186-
behavior. You can't modify it.!
186+
behavior. You can't modify it!
187187
188188
`C` **does not** have a String type, use `char` type and create an `array` of characters
189189
@@ -192,18 +192,18 @@ behavior. You can't modify it.!
192192
```c
193193
int time = 20;
194194
if (time < 18) {
195-
printf("Goodbye!");
195+
printf("Goodbye!\n");
196196
} else {
197-
printf("Good evening!");
197+
printf("Good evening!\n");
198198
}
199199
// Output -> "Good evening!"
200200
int time = 22;
201201
if (time < 10) {
202-
printf("Good morning!");
202+
printf("Good morning!\n");
203203
} else if (time < 20) {
204-
printf("Goodbye!");
204+
printf("Goodbye!\n");
205205
} else {
206-
printf("Good evening!");
206+
printf("Good evening!\n");
207207
}
208208
// Output -> "Good evening!"
209209
```
@@ -212,7 +212,7 @@ if (time < 10) {
212212

213213
```c
214214
int age = 20;
215-
(age > 19) ? printf("Adult") : printf("Teenager");
215+
(age > 19) ? printf("Adult\n") : printf("Teenager\n");
216216
```
217217

218218
### Switch
@@ -221,10 +221,10 @@ int age = 20;
221221
int day = 4;
222222

223223
switch (day) {
224-
case 3: printf("Wednesday"); break;
225-
case 4: printf("Thursday"); break;
224+
case 3: printf("Wednesday\n"); break;
225+
case 4: printf("Thursday\n"); break;
226226
default:
227-
printf("Weekend!");
227+
printf("Weekend!\n");
228228
}
229229
// output -> "Thursday" (day 4)
230230
```
@@ -403,13 +403,13 @@ switch(day) {
403403
int myNum;
404404

405405
// Ask the user to enter a number
406-
printf("Please enter a number: \n");
406+
printf("Enter a number: ");
407407

408408
// Get and save the number entered by the user
409409
scanf("%d", &myNum);
410410

411411
// Output the number entered by the user
412-
printf("The number you entered: %d", myNum);
412+
printf("The number you entered: %d\n", myNum);
413413
```
414414
415415
### User input string
@@ -418,11 +418,11 @@ printf("The number you entered: %d", myNum);
418418
// create a string
419419
char firstName[30];
420420
// Ask the user to enter some text
421-
printf("Enter your name: \n");
421+
printf("Enter your name: ");
422422
// get and save the text
423423
scanf("%s", &firstName);
424424
// output text
425-
printf("Hello %s.", firstName);
425+
printf("Hello %s.\n", firstName);
426426
```
427427

428428
### memory address
@@ -442,10 +442,10 @@ To access it, use the reference operator (`&`)
442442
443443
```c
444444
int myAge = 43; // an int variable
445-
printf("%d", myAge); // output the value of myAge(43)
445+
printf("%d\n", myAge); // output the value of myAge(43)
446446
447447
// Output the memory address of myAge (0x7ffe5367e044)
448-
printf("%p", &myAge);
448+
printf("%p\n", &myAge);
449449
```
450450

451451
### pointer variable {.col-span-2}
@@ -716,12 +716,12 @@ printf("%c\n", myLetter);
716716
```c
717717
#include <stdio.h>
718718
719-
int main() {
720-
printf("File :%s\n", __FILE__);
721-
printf("Date :%s\n", __DATE__);
722-
printf("Time :%s\n", __TIME__);
723-
printf("Line :%d\n", __LINE__);
724-
printf("ANSI :%d\n", __STDC__);
719+
int main(void) {
720+
printf("File: %s\n", __FILE__);
721+
printf("Date: %s\n", __DATE__);
722+
printf("Time: %s\n", __TIME__);
723+
printf("Line: %d\n", __LINE__);
724+
printf("ANSI: %d\n", __STDC__);
725725
}
726726
```
727727

@@ -764,7 +764,7 @@ When you need to convert a macro parameter to a string constant, use the string
764764
```c
765765
#include <stdio.h>
766766
767-
#define tokenpaster(n) printf ("token" #n " = %d", token##n)
767+
#define tokenpaster(n) printf ("Token " #n " = %d\n", token##n)
768768
769769
int main(void) {
770770
int token34 = 40;
@@ -823,7 +823,7 @@ int main(void) {
823823

824824
```c
825825
int main(void) {
826-
printf("Hello World!");
826+
printf("Hello World!\n");
827827

828828
return 0;
829829
}
@@ -855,7 +855,7 @@ int main() {
855855
}
856856

857857
void myFunction() {// Function definition
858-
printf("Good evening!");
858+
printf("Good evening!\n");
859859
}
860860
```
861861

@@ -864,7 +864,7 @@ void myFunction() {// Function definition
864864
```c
865865
// create function
866866
void myFunction() {
867-
printf("Good evening!");
867+
printf("Good evening!\n");
868868
}
869869

870870
int main() {
@@ -918,7 +918,7 @@ int myFunction(int x) {
918918
}
919919

920920
int main() {
921-
printf("Result: %d", myFunction(3));
921+
printf("Result: %d\n", myFunction(3));
922922
return 0;
923923
}
924924
// output 8 (5 + 3)
@@ -932,10 +932,10 @@ int myFunction(int x, int y) {
932932
}
933933
934934
int main() {
935-
printf("Result: %d", myFunction(5, 3));
935+
printf("Result: %d\n", myFunction(5, 3));
936936
// store the result in a variable
937937
int result = myFunction(5, 3);
938-
printf("Result = %d", result);
938+
printf("Result = %d\n", result);
939939
940940
return 0;
941941
}
@@ -950,7 +950,7 @@ int sum(int k);
950950

951951
int main() {
952952
int result = sum(10);
953-
printf("%d", result);
953+
printf("%d\n", result);
954954

955955
return 0;
956956
}
@@ -970,10 +970,10 @@ int sum(int k) {
970970
#include <math.h>
971971
972972
void main(void) {
973-
printf("%f", sqrt(16)); // square root
974-
printf("%f", ceil(1.4)); // round up (round)
975-
printf("%f", floor(1.4)); // round down (round)
976-
printf("%f", pow(4, 3)); // x(4) to the power of y(3)
973+
printf("%f\n", sqrt(16)); // square root
974+
printf("%f\n", ceil(1.4)); // round up (round)
975+
printf("%f\n", floor(1.4)); // round down (round)
976+
printf("%f\n", pow(4, 3)); // x(4) to the power of y(3)
977977
}
978978
```
979979

@@ -1028,13 +1028,13 @@ int main() {
10281028
struct myStructure s1;
10291029
strcpy(s1. myString, "Some text");
10301030
// print value
1031-
printf("my string: %s", s1.myString);
1031+
printf("My string: %s\n", s1.myString);
10321032
10331033
return 0;
10341034
}
10351035
```
10361036

1037-
Assigning values ​​to strings using the `strcpy` function
1037+
Assigning values to strings using the `strcpy` function
10381038

10391039
### Accessing structure members {.row-span-2}
10401040

@@ -1100,7 +1100,7 @@ struct myStructure s1 = {
11001100
s1.myNum = 30;
11011101
s1.myLetter = 'C';
11021102
// print value
1103-
printf("%d %c %s",
1103+
printf("%d %c",
11041104
s1.myNum,
11051105
s1.myLetter);
11061106
```

0 commit comments

Comments
 (0)