Skip to content

Commit b184212

Browse files
committed
Fix typos
1 parent 21db154 commit b184212

File tree

10 files changed

+29
-30
lines changed

10 files changed

+29
-30
lines changed

chapter01/1-14.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int main(void)
3131
printf("%c ", i + '0'); /* print histogram labels */
3232
for (j = 1; j <= characters[i]; ++j)
3333
printf("* ");
34-
if (characters[i] != EMPTY) /* skip not inputed charachters */
34+
if (characters[i] != EMPTY) /* skip character */
3535
printf("\n");
3636
}
3737

chapter01/1-16.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int main(void)
5353
if (len == MAXLINE - 1 && /* test for length and previous input */
5454
line[MAXLINE - 1] != '\n') {
5555
copy(longest, line); /* save the string */
56-
longest[MAXLINE - 2] = '\n'; /* insert a newline charcter before
56+
longest[MAXLINE - 2] = '\n'; /* insert a newline character before
5757
the null character */
5858
max = len;
5959
max += getLine(line, MAXLINE); /* save the value of max */
@@ -65,8 +65,8 @@ int main(void)
6565
if (max > 0) /* there was a line */
6666
printf("%s", longest);
6767

68-
if (max >= MAXLINE - 1) { /* print warnning message */
69-
printf("Warnning: The longest line is %i characters long.\n", max);
68+
if (max >= MAXLINE - 1) { /* print warning message */
69+
printf("Warning: The longest line is %i characters long.\n", max);
7070
printf("\t Only showing the first %i characters\n", MAXLINE);
7171
}
7272
return 0;

chapter01/1-20.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* input with the proper number of blanks to space to the next tab stop. Assume
44
* a fixed set of tab stops, say every n columns. Should n be a variable or a
55
* symbolic parameter.
6-
* By Faisal Saadatmad
6+
* By Faisal Saadatmand
77
*/
88

99
/*
1010
* Answer: it is wiser to use a symbolic parameter for the value n rather than
11-
* a gloabl variable. The value of n should remain constant throughout the
11+
* a global variable. The value of n should remain constant throughout the
1212
* program, for a change in n would break algorithm in functions that depend on
1313
* a specific value of n. If need be, it is better to change the value of n in
1414
* a function through a local variable instead.

chapter01/1-21.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
22
* Exercise 1-21. Write a program entab that replaces strings of blanks by the
33
* minimum number of tabs and blanks to achieve the same spacing. When either a
4-
* tab or a singl blank would suffice to reach a tab stop, which should be give
4+
* tab or a single blank would suffice to reach a tab stop, which should be give
55
* preference?
6-
* By Faisal Saadatmad
6+
* By Faisal Saadatmand
77
*/
88

99
/*
10-
* Answer: in such a case, a singal space is given preference, because otherwise a change
11-
* to the value of the tab stop (n) would distored the single space.
10+
* Answer: in such a case, a signal space is given preference, because otherwise a change
11+
* to the value of the tab stop (n) would distort the single space.
1212
*/
1313

1414
#include <stdio.h>
@@ -38,7 +38,7 @@ int getLine(char s[], int lim)
3838
return i;
3939
}
4040

41-
/* count function: counts the occurremces of a character in a string */
41+
/* count function: counts the occurrences of a character in a string */
4242
int count(char s[], char c, int p)
4343
{
4444
int nC = 0; /* number of c occurrences in s[] */

chapter01/1-22.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void foldLine(char line[], char fldLine[], int lineLen)
5252
/* line is outside of a word or if is made up of one word. */
5353
if (line[i] == ' ' || line[i] == '\t' || wsPos == 0)
5454
fldLine[i] = '\n'; /* break line at current position */
55-
/* line is insdie of a word */
55+
/* line is inside of a word */
5656
else {
5757
fldLine[wsPos] = '\n'; /* break line at the previous ws */
5858
i = wsPos; /* read from break point */

chapter01/1-23.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int getLine(char s[], int lim)
4040

4141
/* findComment function: searches line[] for the first occurrence of the first
4242
* character of a C comment notation and returns the location on finding a single
43-
* line comment or -1 on failiure */
43+
* line comment or -1 on failure */
4444
int findComment(char line[], int notation)
4545
{
4646
int i, j;
@@ -61,7 +61,7 @@ int findComment(char line[], int notation)
6161
}
6262

6363
lookForQuote = YES;
64-
/* line[x - 1] check handles escape squences. It is unnecessary for the
64+
/* line[x - 1] check handles escape sequences. It is unnecessary for the
6565
* start of the quote but is added for the sake of correctness. */
6666
for (i = 0; line[i] != '\0'; ++i) {
6767
if (line[i] == comment[0] && line[i + 1] == comment[1]) {
@@ -84,15 +84,15 @@ int findComment(char line[], int notation)
8484
if (location > quoteStart && location < quoteEnd)
8585
location = -1; /* not a C comment */
8686

87-
/* check if notation is inside a muli-line double quotation marks */
87+
/* check if notation is inside a multi-line double quotation marks */
8888
if (location >= 0 && quoteStart >= 0 && quoteEnd < 0)
8989
// if (location < quoteStart)
9090
location = -1; /* not a C comment */
9191

9292
return location;
9393
}
9494

95-
/* delComment function: deletes C comments from line stringn stores result in
95+
/* delComment function: deletes C comments from line string stores result in
9696
* modLine */
9797
int delComment(char line[], char modLine[], int start, int end)
9898
{
@@ -109,7 +109,7 @@ int delComment(char line[], char modLine[], int start, int end)
109109
else if (start >= 0 && end < 0)
110110
for (i = 0; i < start; ++i)
111111
modLine[i] = line[i];
112-
/* end but no start - move text after comment to the begeining of line */
112+
/* end but no start - move text after comment to the beginning of line */
113113
else if (start < 0 && end >= 0)
114114
for (j = end + 1; line[j] != '\0'; ++j) {
115115
modLine[i] = line[j];
@@ -125,7 +125,7 @@ int delComment(char line[], char modLine[], int start, int end)
125125
}
126126
}
127127

128-
/* end of line formating */
128+
/* end of line formatting */
129129
if (start < 0 && end < 0)
130130
modLine[0] = '\n';
131131
else if (start >= 0 && end < 0) {
@@ -145,7 +145,7 @@ int delComment(char line[], char modLine[], int start, int end)
145145
}
146146

147147
/* delBlanklin function: deletes a line if it's blank. Returns 1 on success
148-
* and 0 on faliure */
148+
* and 0 on failure */
149149
int delBlankLine(char s[])
150150
{
151151
int i, notBlankLine;

chapter01/1-24.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int getLine(char s[], int lim)
4040

4141
/* findComment function: searches line[] for the first occurrence of the first
4242
* character of a C comment notation and returns the location on finding a single
43-
* line comment or -1 on failiure */
43+
* line comment or -1 on failure */
4444
int findComment(char line[], int notation)
4545
{
4646
int i, j;
@@ -61,7 +61,7 @@ int findComment(char line[], int notation)
6161
}
6262

6363
lookForQuote = YES;
64-
/* line[x - 1] check handles escape squences. It is unnecessary for the
64+
/* line[x - 1] check handles escape sequences. It is unnecessary for the
6565
* start of the quote but is added for the sake of correctness. */
6666
for (i = 0; line[i] != '\0'; ++i) {
6767
if (line[i] == comment[0] && line[i + 1] == comment[1]) {
@@ -84,15 +84,15 @@ int findComment(char line[], int notation)
8484
if (location > quoteStart && location < quoteEnd)
8585
location = -1; /* not a C comment */
8686

87-
/* check if notation is inside a muli-line double quotation marks */
87+
/* check if notation is inside a multi-line double quotation marks */
8888
if (location >= 0 && quoteStart >= 0 && quoteEnd < 0)
8989
// if (location < quoteStart)
9090
location = -1; /* not a C comment */
9191

9292
return location;
9393
}
9494

95-
/* delComment function: deletes C comments from line stringn stores result in
95+
/* delComment function: deletes C comments from line string stores result in
9696
* modLine */
9797
int delComment(char line[], char modLine[], int start, int end)
9898
{
@@ -109,7 +109,7 @@ int delComment(char line[], char modLine[], int start, int end)
109109
else if (start >= 0 && end < 0)
110110
for (i = 0; i < start; ++i)
111111
modLine[i] = line[i];
112-
/* end but no start - move text after comment to the begeining of line */
112+
/* end but no start - move text after comment to the beginning of line */
113113
else if (start < 0 && end >= 0)
114114
for (j = end + 1; line[j] != '\0'; ++j) {
115115
modLine[i] = line[j];
@@ -125,7 +125,7 @@ int delComment(char line[], char modLine[], int start, int end)
125125
}
126126
}
127127

128-
/* end of line formating */
128+
/* end of line formatting */
129129
if (start < 0 && end < 0)
130130
modLine[0] = '\n';
131131
else if (start >= 0 && end < 0) {
@@ -153,7 +153,7 @@ int findCharacter(char line[], char symbol[], int charsCount[], int len)
153153

154154
quoteState = OUT;
155155
for (i = 0; i <= len ; ++i)
156-
/* line[x - 1] check handles escape squences. */
156+
/* line[x - 1] check handles escape sequences. */
157157
for (j = 0; line[j] != '\0'; ++j)
158158
if (quoteState == OUT && line[j] == '\"' && line[j - 1] != '\\')
159159
quoteState = IN;

chapter01/1-3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Exercise 1-3. Modify the temperature conversion program to print a heading
33
* above the table.
4-
* By Fasial Saadatmand
4+
* By Faisal Saadatmand
55
*/
66

77
#include <stdio.h>

chapter01/1-4.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main(void)
1414
upper = 300; /* upper limit */
1515
step = 20; /* step size */
1616

17-
fahr = lower;
17+
fahr = celsius = lower;
1818

1919
printf("Celsius\t\tFahrenheit\n");
2020

@@ -24,6 +24,5 @@ int main(void)
2424
fahr = fahr + step;
2525
celsius = celsius + step;
2626
}
27-
2827
return 0;
2928
}

chapter01/1-6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int main(void)
1111

1212
while ((c = getchar()) != EOF) /* note operator precedence */
1313
printf("%i\n", c);
14-
14+
1515
printf("%i\n", c);
1616

1717
return 0;

0 commit comments

Comments
 (0)