Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

pointers on text file?

Hi everybody..

I have a question about pointers and text files..

Well the case is so, that I have write a program for shcool, where I got a long list of soccer games as txt file.
I have to use that txt. to find out on which of the matches the teams have scoret most of the goals.

Now the problem here is, I don't have a clue about, how I can use the data that is inside the txt..

This is what I have for now..
[code]#include
#include
#define MAX_LEN 200

int main(void)
{
FILE *inp;
char name[MAX_LEN], name2[MAX_LEN];
int score;
long maal;

inp =fopen("superliga.txt", "r");

if (inp != NULL) {

fscanf(inp, "%s ", name);

printf("%s ", name);
fclose(inp);
}
else {
printf("Cannot find the file");
}

return 0;

}[/code]

- Is there a way to use sscanf on the file??
I want to be able to get some data from the txt file and be able to do some math and print it out again..
Any idea is appreciated

Comments

Sign In or Register to comment.