Okok, I used that method...
with this file
------------------------
32
abcdefg
22
hijklm
45
nopqr
------------------------
this code:
Code:
#include <stdio.h>
#define MAX 100
#define SOURCE2 "pattern2.txt"
int main(void)
{
char b1[MAX];
char b2[MAX];
FILE *fp = fopen(SOURCE2, "r");
while ( fgets( b1, MAX, fp ) != NULL ) {
if ( fgets( b2, MAX, fp ) != NULL ) {
printf("%s", b1);
printf("%s", b2);
}
}
printf("\nb1[0] = %c", b1[0]);
printf("\nb2[0] = %c", b2[0]);
fclose(fp);
return 0;
}
and got this output:
------------------------------
32
abcdefg
22
hijklm
45
nopqr
b1[0] =
b2[0] = n
------------------------------
It works inside the 'if' function but i dont really want to anything within the if function (if thats possible). I want the numbers 32 or 22 or 45 to stay as numbers so i can do comparisons and formulas with them much later on. And I want 32 to be associated with abcdefg.
It says its my main() function, but i actually want to make it into a function that can be called by my main function, so that it can return a number (32) and an array of characters (abcdefg). And then get another pair and return it and then another pair...up a around 50 -100 pairs(i just know its alot of pairs).
Sorry, your method may work for what im trying to do but im a supernewb at this stuff, so any explanations and further help would be good, thanks!