Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7921079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:27:08+00:00 2026-06-03T16:27:08+00:00

In this function findBookByTitle what is supposed to happen is fp is opened and

  • 0

In this function findBookByTitle what is supposed to happen is fp is opened and if a title matches the one given to function it will print the title. It is assumed titles are unique so once a match is found it can stop searching. My problem is i’m not entirely sure how to match the title to something in a file. This is what I have so far…

    void findBookByTitle(FILE* fp, char title[])
    {
       FILE * fp = fopen(fp, "r");
       while(!EOF && *fp = title){
          printf("Title: <%c> \n", title);
       }
       if(EOF && *fp != title ){
          printf("No books match the title: <%c> ", title);
       }
    }

As well when I compile I get a few errors, it might be pointless to address these as my function remains incomplete but a few of these really confuse me.

34: error: ‘fp’ redeclared as different kind of symbol
32: note: previous definition of ‘fp’ was here
34: warning: passing argument 1 of ‘fopen’ from incompatible pointer type
/usr/include/stdio.h:251: note: expected ‘const char * restrict‘ but argument is of type ‘struct FILE *’
35: error: invalid operands to binary && (have ‘int’ and ‘FILE’)
38: error: invalid operands to binary != (have ‘FILE’ and ‘char *’)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:27:09+00:00Added an answer on June 3, 2026 at 4:27 pm
    1. Your function is declared as taking a FILE * as its first argument, but it then proceeds to treat that argument as if it’s a filename and try to open another FILE * (with the same name!) using it. Make up your mind on whether the argument is a FILE * or a char *, and change your code accordingly.

    2. You are trying to use EOF to test for EOF on fp. It’s not quite that simple. Try feof(fp) instead.

    3. You are trying to read from fp using *fp = title (and *fp != title). This doesn’t make any sense at all. You need to use a function to read from the file pointer, such as fgets or fscanf.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Example: /** * This function will determine whether or not one string starts with
Using this function: perl -e 'use Time::Local; print timelocal(00,00,00,01,01,2000),\n;' It will return an epochtime
This function is supposed to set descending order numbers on an IEnumerable<Order>, but it
This function alerts right totalqt only when I check checkboxes one by one. But
This function is from the book Programming Collective Intelligence, and is supposed to calculate
given this function: Public Function Search(ByVal StartIndex As Integer, _ ByVal MaxResults As Integer,
This function implements the API to change process title: http://lxr.evanmiller.org/http/source/os/unix/ngx_setproctitle.c 59 for (i =
This function will take a particular node of linked list and make it Last
this PHP RGB brightness altering function works partially: It misses one zero 0 at
This function will be using in general ajax calss: function f_AjaxFunction(_param) { var objectWillReturn;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.