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

  • Home
  • SEARCH
  • 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 8293061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:42:08+00:00 2026-06-08T13:42:08+00:00

std::string systemStr = C:\\gcc1\\gccxml.exe ; systemStr += \ ; systemStr += argv[1] ; std::cout<<Header

  • 0
std::string systemStr = "C:\\gcc1\\gccxml.exe ";
    systemStr += "\"" ;
    systemStr += argv[1] ;
    std::cout<<"Header File is:"<<argv[1]<<endl;

In the above code snippet, argv[1] represents the name of the header file. I want to open this header file and search for #ifdefs that may be present. How do I go about doing this? The problem is that argv[1] is a string. I’m sorry if I’m unclear.

  • 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-08T13:42:09+00:00Added an answer on June 8, 2026 at 1:42 pm

    How about something like this…

    std::cout<<"Header File is:"<<argv[1]<<endl;
    
    std::ifstream file(argv[1]);
    int lineNum = 0;
    bool hasIfdef = false;
    
    while( file.good() )
    {
        std::string line;
        std::getline( file, line );
        lineNum++;
    
        if( line.find("#ifdef") != std::string::npos ||
            line.find("#ifndef") != std::string::npos )
        {
            std::cout << "Line " << lineNum << ": " << line << std::endl;
            hasIfdef = true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

int main(void) { std::string foo(foo); } My understanding is that the above code uses
std::string s(??<); std::cout << s << std::endl; Why does that output { instead of
My old Boost code: std::string CombinePath(const char* left, const char* right) { boost::filesystem::path p
void insert_string( std::vector<std::string> & strings, const std::string &s ) { std::vector<std::string>::iterator it=lower_bound(strings.begin(),strings.end(),s); if(strings.size()>0) std::cout<<*it<<
I have this code: std::string name = kingfisher; char node_name[name.size()+1]; strcpy(node_name,name.c_str()); node_name[name.size()] = '\0';
I have this static std::string exec(char* cmd) { FILE* pipe = _popen(cmd, r); if
Can anyone beat the performance of my integer to std::string code, linked below? There
std::string token, line(This is a sentence.); std::istringstream iss(line); getline(iss, token, ' '); std::cout <<
std::string s(foo); sprintf(buf,%s,s); Why at least under MSVC 2010 this line of code doesn't
I have code: std::string firstFile = boost::filesystem::path(first->name()).leaf(); But get error: error conversion from ‘boost::filesystem3::path’

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.