vendredi 20 février 2015

C Replace one character in an char array by another

I have the following C Code



#include <stdio.h>
int main(void){
char c[] = "ABC"
printf("%s ", c);
c[1] = 'B';
printf("%s", c);
return 0;
}


The output I want is ABC BBC but the output I get is ABC ABC. How can I replace the first character in an String / char array?


Aucun commentaire:

Enregistrer un commentaire