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 7749735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:06:50+00:00 2026-06-01T11:06:50+00:00

When I compile my program, I get three undefined reference to ‘PrintArgv(…)’ errors. I

  • 0

When I compile my program, I get three “undefined reference to ‘PrintArgv(…)'” errors. I have searched but I cannot find the reason why I am getting these errors. Here is my code:

    #include "tools.hpp"

enum ARG_T {COMMAND, SWITCH, ARGUMENT};
void ReadArgs(int, char**, ofstream&);
void PrintArgv(char*, ARG_T, ofstream&);


int main(int argc, char* argv[])
{
    ofstream fout;
    try{
        fout.open("P1Ford.txt", ios::out | ios::app);
    }
    catch(...)
    {
        //fatal("Could not open file P1Ford.txt");
        cout << "Could not open file P1Ford.txt" << "\n";
        return -1;
    }

    ReadArgs(argc, argv, fout);

    fout.close();
    return 0;
}

/*-----------------------------------------------------------------------------
This function takes the values passed in through the command line
then examines each one to determine if it is the command, a switch or
an argument. Then passes it to a function to print it to the file.
-----------------------------------------------------------------------------*/
void ReadArgs(int argc, char* argv[], ofstream& fout)
{
    for(int c=0; c<argc; ++c)
    {
        if(c == 0) PrintArgv(argv[c], COMMAND, fout);
        else if(strncmp(argv[c], "-", 1) == 0) PrintArgv(argv[c], SWITCH, fout);
        else if(strncmp(argv[c], ">", 1) == 0) ;
        else PrintArgv(argv[c], ARGUMENT, fout);
    }
}

/*-----------------------------------------------------------------------------
This function prints the argument in the correct format
Command <command>
   Switch <switch>
   Argument <agrument>
   Argument <argument>
-----------------------------------------------------------------------------*/
void PrintArgv(char* val, ARG_T type, ostream& fout)
{
    if(type == COMMAND) fout << "Command " << val << "\n";
    if(type == SWITCH) fout << "\t" << "Switch " << val << "\n";
    if(type == ARGUMENT) fout << "\t" << "Argument " << val << "\n";
}

The function ReadArgs is where I am getting the errors. Each call to PrintArgv gives me the error. I am using G++ 4.6.1.

  • 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-01T11:06:51+00:00Added an answer on June 1, 2026 at 11:06 am

    Your prototype has a parameter of type ofstream & and your header has one of type ostream &. This means that the implementation of PrintArgv is actually declaring a new function. You call the one you specified a prototype for, though, which has no body because you inadvertently created a new function instead of defining the body of the original one.

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

Sidebar

Related Questions

I have a simple openGL D program that compiles, but I can't get it
I have a simple openGL D program that compiles, but I can't get it
I wanted to use boost::thread in my program, but get the following compiler error
Lets say I have files: Libs: one.cpp, one.h two.cpp, two.h three.cpp, three.h Program: program.cpp
i get the fallowing error when i compile program: vandenynas.cpp(19) error C2662: 'skaiciavimas::showst' :
i'm trying to get into opengl programming, but fail to compile my first very
I am tring to compile a program in verilog but there is a basic
My program works but am getting these warning when i compile it. [javac] warning:
The situation is simple, but strange. When i compile my program without the LinearAlgebra.o
I have a problem while trying to compile and link my program with dmalloc.

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.