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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:41:01+00:00 2026-05-31T12:41:01+00:00

Assume I have char **argv . How do I determine its size? I have

  • 0

Assume I have char **argv. How do I determine its size?

I have a string – an example would be: sleep 30 & that is held in argv. I would like to be able to access the last array in *argv. In this case, the last array contains &. How can I access it? strlen(argv) doesn’t seem to work properly. sizeof() obviously wouldn’t work properly because **argv is a pointer.

Note: I am not talking about **argv as an argument in main(), therefore, I do not have argc or any other indicator of how long the string is.

  • 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-05-31T12:41:03+00:00Added an answer on May 31, 2026 at 12:41 pm

    EDIT: Edited to work with a custom array of strings. A NULL pointer indicates the end of the array. Although this declares an array of 4 strings, this method could be used with a dynamically sized array.

    #include <stdio.h>
    
    int main()
    {
        char* custom[4] = { "sleep", "30", "&", NULL };
        int last;
        for (last = 0; custom[last + 1]; last++);
        printf("%i - %s\n", last, custom[last]);
        return 0;
    }
    
    // ./a.out
    // > 2 - &
    

    For this to work for you, you would have to edit your program to explicitly include an extra NULL string in your char** when you build it. Without that indicator, the address after the last string wouldn’t necessarily be NULL, so you could include garbage in the count or cause a segmentation fault.

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

Sidebar

Related Questions

Assume I have char **argv , so that argv[0] = some string and argv[1]
Possible Duplicate: std::vector<std::string> to char* array I have to call a c function that
Assume I have char **argv . First, how can I print out all the
Assume we have a string like the following : ,34,23,4,5,634,23,12,5,4,3,1234,23,54,,,,,,,123,43,2,3,4,5,3424,,,,,,,,123,,,1234,,,,,,,45,,,56 How can we convert
Assume I have a class class A { char *attr1,*attr2; public: . . .
Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
Assume I have an ASP.NET MVC app that's not doing anything too fancy (no
Assume we have a method like this: public IEnumerable<T> FirstMethod() { var entities =
If for example I have a ptr to a string and move ptr to
I have a char byte that I want to convert to an int. Basically

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.