bsudhir6 26 Newbie Poster

I wrote a program for counting and printing characters in a data link layer frames i've succeeded in getting output for the first frame but for the other frames it showed not valid please help in the code

If i give an input as 6sudhi4div then the integer in the input is the size of frame and the characters after the integer are the contents of the frame including the size of the frame( for example size 6 contents : 6sudhi)

The code is

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<numver.h>
#include<stdlib.h>

#define N 644

void main()
{
	int i,l,c,f,m;
	char s[N];

	i=l=c=f=m=0;

	printf("Enter the dataframe");
	scanf("%s",s);

	l=strlen(s);


	while(l!=0)
	{

		if(isnum(s[i])==1)
			{
				f++;
				c=i+s[i]-1;
				for(m=i+1;m<=c;m++)
				{
					if(isnum(s[m])==1)
						{
							printf("Its an invalid dataframe");
							getch();
							exit(0);
						}
				  else
				  {
					printf("Frame %d contains following charecter",f);
					printf("\t %c",s[m]);
					l--;
				}
		  }
		}
		i=i+s[i];
  }
getch();
}

Thanks

Ancient Dragon commented: Thanks for using code tags on your first post :) +26