Advertisement
hamaXD

CPT lab02-02 v.2

Aug 29th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. char* find_char(char s[], int c);
  4.  
  5. int main(){
  6.   char str[128];
  7.   char c,*ch,*x;
  8.   char zero = NULL, *null;
  9.   printf("S:");
  10.   gets(str); fflush(stdin);
  11.   printf("C:");
  12.   scanf("%c",&c);
  13.   ch = &c ;
  14.   printf("&C in main is %d\n",ch);
  15.   printf("C in main is %c\n",*ch);
  16.   printf("'C' in main is %d\n",c);
  17.   null = &zero;
  18.   x = find_char(str,c);
  19.   if(*x == *null){
  20.     printf("Next position alphabet in main  is %s\n",*x);
  21.     printf("=%s",*x);
  22.   }else{
  23.     printf("Next position alphabet in main  is %c\n",*x);
  24.     printf("=%c",*x);
  25.   }
  26.  
  27.  
  28.   return 0;
  29. }
  30. char* find_char(char s[], int c){
  31.     char *ch,*x,*null;
  32.     *ch = c;
  33.     char zero = NULL;
  34.     printf("C in function is %c\n",*ch);
  35.     printf("&C in function is %d\n",ch);
  36.     int n = strlen(s);
  37.     printf("Size S in function is %d\n",n);
  38.     int i=0;
  39.     while(i<n){
  40.         if(*ch == '\0'){
  41.             null = &zero;
  42.             return null;
  43.         }
  44.         else if(*ch==s[i]){
  45.             printf("S = C in while is %c\n",s[i]);
  46.             x = &(s[i+1]);
  47.             printf("Next Position alphabet in while is %c\n",*x);
  48.             return x;
  49.    
  50.            
  51.         }
  52.         i++;
  53.     }
  54.     null = &zero;
  55.     return null;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement