just a quick ques :P lets say i hav five names in my input file. i wanna read the 3rd name in my program. how do i do it? (remember i dont wanna read the whole file..i know how to!)

Describe your input file.

Describe your input file.

it has the names like: steve
jerry
susy
......, so on.
its just a regular input file. wat im tryin to do is to compare those names with strcmp function. so i hav to use pointers. lets say i have:

char *name[3]; // thats an array w/ three names rite?

then i read the input file to the array:

infile<<name; // in for loop with int i...

so when i wanna compare steve and jerry, i say

strcmp(name, name[i+1]). but it didnt work. why?

it has the names like: steve
jerry
susy
......, so on.

So... each name on its own line; newline separated strings.

its just a regular input file. wat im tryin to do is to compare those names with strcmp function. so i hav to use pointers. lets say i have:

char *name[3]; // thats an array w/ three names rite?

No. It's an array of 3 pointers to char.

then i read the input file to the array:

infile<<name; // in for loop with int i...

so when i wanna compare steve and jerry, i say

strcmp(name, name[i+1]). but it didnt work. why?

Sometimes I feel like playing 20 questions and guessing the actual code and a sample input file, but not tonight. I can't read your mind. (Others may do better, however.)

But first, make sure pointers point to something.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.