[ create a new paste ] login | about

Link: http://codepad.org/LojYsqtH    [ raw code | output | fork ]

nel - C, pasted on Oct 21:
/*

1. Passing to function stringCheck pointer to the first (input string) and second
(output string) strings.
2. Create 'unsigned char temp' to store current array-character value, for comparsion then.
3. Create counting variable for count equal (a==b,b==c and so) values
4. Fill the same array elements with 0, last with '-';
5. Fill (output string) array with edited string, but if(currChar==0), curChar++; ;-)
6. Print new (output) string.

http://forums.data.bg/index.php?showtopic=1884966

*/

#include <stdio.h>
 
int stringCheck(char *in_str, char *out_str);

#define MAX 50 /* MAX = 50 */

 int main(void)
 {
     char in_str[MAX] = "abcdeop";
     char out_str[MAX] = "0";

     stringCheck(in_str, out_str);
     
     printf("%s", out_str);

printf("\n--- end out_str --- \n");

     printf("\n%s", in_str);
	 return 0;
 }

int stringCheck(char *in_str, char *out_str)
 {
	 // working variables declarations 
	 unsigned char temp;

	 // let's compare ;-)
	 while(*in_str!='\0') {
		 temp = *in_str;

		 // IF TRUE
		 if(*(in_str+1)==(temp+1)) {
	             continue; 
                    // printf("for %c == %c: yes\n", *(in_str+1), (temp+1));
		 }
                 
                else { *out_str=*in_str; }
		 
		 *in_str++;
                 *out_str++;	 
}



         return 0;

	 //getch();
}


Output:
1
Timeout


Create a new paste based on this one


Comments: