Here´s the complete code:
It does everything twice.
Code:
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
//-------------------------------------------------
void main()
{
int i,j;
int x[10], y[10];
char buff[6];
FILE *Koordinaten;
Koordinaten=fopen("hpgl.txt","r"); //reads from hpgl.txt
clrscr();
//------------------------------------------------------------------------------
while(i<4&&fgets(buff,sizeof(buff),Koordinaten)!=NULL)//do10x orempty buff
{
if (sscanf(&buff[2],"%d%d",&x[i],&y[i])==2) //begin buff3 and nimm nur 2int
{
//cout<<"i="<<i<<" x="<<x[i]<<" y="<<y[i]<<"\n";
printf("i=%d x=%d y=5d\n",i,x[i],y[i]);
i++;
}
}
getch();
}
Here it takes everything, not only the first nr.:
Code:
/**********************
//TestBuff10 *
/**********************/
#include<windows.h>
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
int main()
{
char buff[6] ;
int i;
int x[10];
FILE *HexCode;
HexCode = fopen("hex.txt","r"); //reads hex.txt
clrscr();
while (i<10 && fgets(buff,sizeof(buff),HexCode)!= NULL)
{
if (sscanf(&buff[0], "%x", &x[i])==1)
{
printf(" %x\n",x[i]); i++;
}
}
getch();
}