**I try to truncate this string but it always gives me this answer:
**"-bash-3.00$ a.out String: xxxxxxxxxxooooooooooÿ>Á¬ÿ>ð¬"
//**Please what should I do? Thanks.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char a[10][63];
char line[50] = "xxxxxxxxxxooooooooooaaaaaaaaaakkkkkkkkkkkk";
//Tries to truncate "line" to 20 characters
line[20] = '\0';
//copying line to each character at a time
int x;
for(x = 0; x < 20; x++)
{
a[0][x] = line[x];
}
//Printing out the copied character.
printf("String: %s\n", a[0]);
}
Aucun commentaire:
Enregistrer un commentaire