I have a small problem. I am a begginer in C programming . I need so help please.

my project i am working on is in image. I use a camera to take a number in very small part for example ( 0901) but sometime those component have defect next to the number therefore is the number will come with (??09?01??).

I do not unknow if my code is good .the number is stored in the folder below.

but I would like help how can I make it just to take 4 number only without (?)also should i need only retur 0 if the number exist and 1 if the number is bigger than 4 ?

#include "stdafx.h"
#include <stdio.h>
#include <string.h>



int main()
{
  FILE*fp;


	  fp=fopen("C:\\Users\\Noy\\Desktop\\tet.txt","w");
	  char buf[10];
	  int i;
	  char *foo = "12?12??34"; 
	  int l = strlen(foo);

	if(fp !=NULL)
	{
		for(i=0;i<l;i++)
		{  
		 if(*foo=='?')
			 buf[i] = ' ';
		 else
			 buf[i] = *foo;
			 *foo++;
		}

	 for(i=0;i<l;i++)
  
	fprintf(fp,"%c",buf[i]);
  
 
	fclose(fp);
		
	}	  
		return 0;
}

If you don't want question marks messing up your numbers, why put them in char *foo? Your logic and English both leave me with question marks. ;)

Go over each char of the string stored in foo.
If the char is a question mark, ignore it
Else keep it

Is the final product an integer or a char array ?

char ???. ok i did mamange to make it work . you can call foo ( number) and buf ( filename) but the problem is i need to retrieve the number (01??12?) from the file tet.txt and then put it in char*foo??. I did manage to read

see code bellow if you compile you will understand what i want to do

#include "stdafx.h"
#include<stdlib.h>
#include <stdio.h>
#include <string.h>
#include<iostream>




int main()
{


 FILE*fp;


	
	 
	 char filename[10];

	 // int i;
	  //char *number= "??1?3?4";
	 // int l = strlen(number);
      // int number;


	


 fp=fopen("C:\\Users\\Noy\\Desktop\\tet.txt","r");
 
	


// int l = strlen(number);
	if(fp !=NULL)
	{
		
		//for(i=0;i<l;i++)
		//{  
		// if(*number=='?')
			// filename[i] = ' ';
		// else
			// filename[i] = *number;
			// *number++;
		//}

	// for(i=0;i<l;i++)
  
	fscanf(fp,"%s",filename);
	printf("%s\n",filename);
	getchar();
		
		
		//fprintf(fp,"%c",filename[i]);
  
	 
	
    
	fclose(fp);
		
	}	  
		return 0;

}

I store the number (??1?3?4) in tet.txt and then i can read the file but now i tried to use the number and remove the question marque???

Do what abhimanipal said.

I abhimanipal can you please give me a hint at list because i already did it and it doesn't work

Your if on line 41... I think it should be

*(number + i)

To check if the char in question is a question mark write

if(*(number+i)=='?')

Running this loop the correct number of times is of essence

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.