@@ -187,4 +187,67 @@ Um arquivo texto é caracterizado pela presença de uma variedade mais restrita
187
187
- 65 a 90, letras maiúsculas de 'A' a 'Z'
188
188
- 97 a 122, letras minúsculas de 'a' a 'z'
189
189
- Sinais de pontuação espalhados entre as faixas acima
190
- - 127, o último código, é DEL ou ESC
190
+ - 127, o último código, é DEL ou ESC
191
+
192
+ ### Extendidos
193
+
194
+ - ISO8859
195
+ - Unicode
196
+ - UTF-8
197
+
198
+ ## A biblioteca ` string ` da LibC
199
+
200
+ - A biblioteca _ string_ , incluída na LibC, apresenta um conjunto de funções para manipulação de strings.
201
+ - Algumas funções notáveis:
202
+ - ` int strlen(char* s) `
203
+ - ` char* strcpy(str* s1, str* s2) `
204
+ - ` int strcmp(str* s1, str* s2) `
205
+ - ` char* strcat(str* s1, str* s2) `
206
+ - Aplicação:
207
+ ``` c
208
+ // ========================================================================
209
+ char * g = " oi" ;
210
+ int tamanho_string = strlen(g);
211
+ // ========================================================================
212
+ // Com inteiros, faz-se:
213
+ int val = 34 ;
214
+
215
+ // Com strings, faz-se:
216
+ char * str = " oi" ;
217
+ // ========================================================================
218
+ // Com inteiros, faz-se:
219
+ int a = 62 ;
220
+ int b;
221
+ b = a;
222
+
223
+ // Com strings, NÃO FUNCIONA:
224
+ char * s = " oi" ;
225
+ char t[256 ];
226
+ t = s; // COPIA APENAS O PONTEIRO , NÃO FAZ A CÓPIAS DOS CARACTERES UM A UM !!
227
+
228
+ // Em vez disso, deve-se fazer:
229
+ char * s2 = " oi" ;
230
+ char * t2;
231
+ strcpy (t, s); // A STRING t RECEBE A CÓPIA CARACTER A CARACTER DE s
232
+ // ========================================================================
233
+ int c = 71;
234
+ int d = 19;
235
+ if (c == d) {...}
236
+ else if (c > d) {...}
237
+ else if (c < d) {...};
238
+
239
+ char* m = "oi";
240
+ char* n = "hi";
241
+ if (strcmp(m, n) == 0) {...} // m == n seria uma comparação de ponteiros, não dos caracteres
242
+ else if (strcmp(m,n) > 0) {...} // m na frente de n na ordem alfabética; m > n não faz sentido
243
+ else if (strcmp(m,n) < 0) {...} // n na frente de m na ordem alfabética
244
+ // ========================================================================
245
+ int x = 5;
246
+ int y = 7;
247
+ y += x; // y passa a valer 12
248
+
249
+ char* u = "oi";
250
+ char* v = "!!";
251
+ strcat(u,v); // u passa a valer "oi!!"
252
+
253
+ ```
0 commit comments