Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************************
- * Name: Liel *
- * q1 *
- * *
- **********************************/
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #define TRUE 1
- #define FALSE 0
- void myFgets(char str[], int len);
- void encoded(char str[], int newStr[]);
- int main (void)
- {
- char str[50]={0};
- char stopStr[]="stop+0000";
- int newStr[50]={0};
- int check=0;
- check=TRUE;
- do{
- printf("pleas enter a string: ");
- myFgets(str, 50);
- if(strcmp(str, stopStr)==0)
- {
- check=FALSE;
- printf("Thank you");
- }
- else
- {
- encoded(str, newStr);
- }
- }while(check);
- return 0;
- }
- void myFgets(char str[], int len)
- {
- fgets(str, len, stdin);
- str[strcspn(str, "\n")]=0;
- }
- void encoded(char str[], int newStr[])
- {
- int plusIndex=0;
- int i=0;
- plusIndex=strcspn(str, "+");
- for(i=0; i<plusIndex; i++)
- {
- newStr[i]=str[i]+(str[plusIndex+i+1]-'0');
- if(newStr[i]>'z')
- {
- printf("%c ",('a'-1)+(str[plusIndex+i+1]-'0') );
- }
- else
- {
- printf("%c ",newStr[i]);
- }
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement