jweinst1
1/21/2016 - 1:35 AM

changes a char in a specific character string

changes a char in a specific character string

#include "stdio.h"

char changeindex(char str[], int index, char newc);
//gets string from input
int main(void) {
    // Disable stdout buffering
    setvbuf(stdout, NULL, _IONBF, 0);
    char received[50];
    printf("say something:");
    scanf("%s", received);
    changeindex(received, 2, 't');
    printf("you said %s", received);
    return 0;
}
//changes a specific character in a string
char changeindex(char str[], int index, char newc) {
    str[index] = newc;
}