From: apothegm AT no DOT spam DOT softcom DOT net (Nathan Thompson) Newsgroups: comp.os.msdos.djgpp Subject: Re: CHARACTER HELP. Date: Sat, 06 Sep 1997 17:20:59 GMT Reply-To: apothegm AT no DOT spam DOT softcom DOT net Message-ID: <34118f97.7545541@news.softcom.net> References: <3411037e DOT 0 AT comnet DOT co DOT nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 206.107.251.126 Lines: 39 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On 6 Sep 97 07:17:18 GMT, Craig Rennie wrote: >Does anybody know how I could go about changing a single character up 3 >characters which have been read from a file? >eg. Reading "c" from a file and converting it to "f". > or reading "%" and converting it to "(". > You can simply add the value '3' to the character. For example: #include int main(void) { FILE *fp; char buffer[512]; int i; if ((fp=fopen("myfile", "rt"))==NULL) { printf("\nCan't open file!\n"); return 1; } fread(buffer, 512, 1, fp); fclose(fp); // convert characters here for (i=0; i<512; i++) { buffer[i]+=3; } // do whatever you want with the buffer here return 0; } Nathan Thompson --------------- Remove 'no.spam.' to reply.