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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:26:37+00:00 2026-05-11T06:26:37+00:00

I have a string in C++ of type const char* passed as argument to

  • 0

I have a string in C++ of type const char* passed as argument to strlen, but it returns void.

it goes like

strlen(astruct.string); 

Thanks..

EDIT: Did some checking,

strlen('test'); 

still gives void.. why?

EDIT: Here’s the image http://img14.imageshack.us/img14/1808/strlen.png

Sorry for being unclear previously. Formatting was not working quite well. Anyway, the confusion was solved by both Evan Teran and Vlad Romascanu. Also take a look at Brian R. Bondy’s answer.

Thanks. Feel free to close.

  • 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. 2026-05-11T06:26:38+00:00Added an answer on May 11, 2026 at 6:26 am

    Referring to your screen shot: your debugger is displaying <void> for strlen(...) when in fact it should display an error.

    You cannot call methods and display their results in the debugger watch. The debugger will only display existing variables and data. It cannot invoke arbitrary methods on demand since the methods can alter the state of the program being debugged in ways that were not anticipated by either the author of the code nor by the debugger.

    What you can do is, in your code, temporarily add:

    size_t tmp_len = strlen(struc.string); 

    then compile, and add tmp_len to the watch.

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

Sidebar

Related Questions

I have a method that returns a list of type string. I want to
I have a set data type: template <class V> struct Set { void add(const
I have a class: class foo { private: std::string data; public: foo &append(const char*
I have a const char* str with a very long string. I need to
I want to get the string name (const char*) of a template type. Unfortunately
I have: unsigned char *foo(); std::string str; str.append(static_cast<const char*>(foo())); The error: invalid static_cast from
I have two functions : void foo(const char * p) and template<size_t T_Size> void
I have string value and Type of some variable (For example int and 32
how to convert a String type to a Int i have a tuple and
We know that string is a reference type , so we have string s=God

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.