I need to compare whether string is equals or not to the following extended char sequence: "———" ( ALT + 0151 code repeated three times) that is in text file. How to do it with function strcmp() ?
A piece of the example text file (TSV):
Piracicaba Av. Armando Salles de Oliveira Lado par 13400-005 Centro Piracicaba Tv. Agostinho Frasson ——— 13400-008 Centro Piracicaba Av. Armando Salles de Oliveira Lado ímpar 13400-010 Centro
When I read the file and print the field is displayed "ùùù" on monitor.
The structure:
typedef struct {
char cidade[50];
char tipoLogradouro[20];
char logradouro[50];
char trecho[30];
char cep[10];
char bairro[50];
} Endereco;
The test is inside 'switch case' and the program is crashing in this part:
case 3:
{
if(strcmp(token, "———") == 0) // Change to "ùùù" and fails too.
strcpy(registro[i].trecho, NULL);
else
strcpy(registro[i].trecho, token);
break;
}
Thanks a lot.
Often in C, you can only use 7-bit ASCII in a quoted string, so for upper ASCII you need to use the \x escape sequence with the hexadecimal code of the character. So, in your case you can type: "\x97\x97\x97", since 97 is hex for 151 decimal.
case 3:
{
if(strcmp(token, "\x97\x97\x97") == 0)
strcpy(registro[i].trecho, NULL);
else
strcpy(registro[i].trecho, token);
break;
}