problem with reading from a file
heres the problem trying to read in a text file(sample below) and read these values into an array, i will use the array to check for valid users.
n123456
origam3
k987654
n290865
heres the code
Code:
#include <stdio.h>
main()
{
FILE *stream;
stream = fopen("passwords1", "r");
if (stream == NULL)
{
printf("File Not Loaded Correctly");
}
char linebuffer[10];
char *users[2];
int i =0;
while(fgets(linebuffer, 10, stream))
{
sscanf(linebuffer,"%s", &users[i]);
printf("%s\n", &users[i]);
i++;
}
printf("\n");
for(i=0;i != 4;i++)
{
printf("Value:%s\n",&users[i]);
}
}
//output produced by first printf with the while loop
n123456
origam3
k987654
n290n29
//output produced from second printf outside of the stream
Value:n123orign290n290n29
Value:orign290n290n29
Value:n290n290n29
Value:n290n29
as u can see the code prints out correctly when accesing the first printf except fot the last one, but not when im accessing the one outside of the loop, this has been doing my head in for ages, any help much apreciated, cheers
a1dutch