Hey im making an encryption program... its going to be a simple one but it will do the job for what i need it for... I need to take a string which is inputed to a sting pointer Via a file... Then i need to add a certain number such as 1 to the letter of each string and put that letter back in the string... for example
i need to change it to bcdeCode:char *s; s = "abcd";
this is what i have so far
Code:#include <stdio.h> /* header file */ #include <stdlib.h> void main(void) { FILE *fp; /* file pointer */ char *i,c; int count; /* open file for output */ if ((fp = fopen("myfile", "w"))==NULL){ printf("Cannot open file \n"); exit(1); } i="abcdef"; /*here is my string*/ for(count=0;(i[count] != '\0'); count++){ c = (i[count] + 28); /*here i convert the integer value to a char*/ /* here i need some way of putting that char back into the string*? } if (fwrite(&i, 2, 1, fp) !=1){ printf("Write error occurred"); exit(1); } fclose(fp); /* open file for input */ if ((fp =fopen("myfile", "r"))==NULL){ printf("Read error occurred"); exit(1); } printf("\ni is %s\n",i); fclose(fp); getchar(); }



LinkBack URL
About LinkBacks



