#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int  main(int argc, char **argv){
 FILE* fp;
 char s[2048];
       char *r1=NULL;
       char *x1=NULL;
       int rectCount=0;
 // Open UI file to read
 fp = fopen("3btn.ui", "r");
 
 if ( fp == NULL ){ 
 printf("File error, can't read! \n");
 }else {
          while( !feof(fp) ) {
                      fgets(s, 2047, fp ); //max 2047 char
                      r1= strstr(s, "<rect>");
          if(r1!=NULL){
	          fgets(s, 2047, fp ); 
              x1=strstr(s,"<x>");
	          rectCount++;
          if(x1!=NULL){
              char num[strlen(x1)]; //N in the array fits in size of x1
              int  j = 0, len;
              len = strlen(x1);
			      for (int i = 0; i < len; i++) {
                          if (x1[i] >= '0' && x1[i] <= '9') {
                               num[j] = x1[i];
                               j++;
                               }
                    }
                  printf("The innner value is: %d\n", atoi(num));
		     }
                   r1=NULL;
	               x1=NULL;
	         }
          };      //end while loop
	printf("\n%d", rectCount);
 fclose(fp);
 }
  return 0;
}
