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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:20:43+00:00 2026-05-26T11:20:43+00:00

i am trying to determine what does this code? #include <cstdlib> #include <iostream> #include<string.h>

  • 0

i am trying to determine what does this code?

#include <cstdlib>
#include <iostream>
#include<string.h>

using namespace std;

char *skip(char *p,int n)
{
    for (;n>0;p++)
        if (*p==0) n--;

    return p;      
}

int main(int argc, char *argv[])
{
    char *p="dedamiwa";
    int n=4;
    cout<<skip(p,n)<<endl;
}

When I run it om dev c++,it wrotes

`basic_string::copy`

When i run it on ideone.com,it wrotes

prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:15: warning: deprecated conversion from string constant to ‘char*’
prog.cpp:18: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
  • 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-26T11:20:44+00:00Added an answer on May 26, 2026 at 11:20 am

    It skips n characters of the char array.

    It interpret the first parameter as a pointer to an array of character
    containing at least n null characters, and return a pointer after the
    n-th such null-character. Per se, there is no undefined behavior if
    you pass correct input to it.

    Since you pass a simple null terminated string, it has undefined
    behavior, as there is only one such null-character in its input. It
    will access memory after the end of the string.

    Concerning the compilation errors, in C++ a constant string is of type
    const char*, not char*, and you should check the return of the system
    function for error. by — Sylvain Defresne

    A version of the code with explicit braces is maybe a little bit
    more readable for you:

    using namespace std;
    char *skip(char *p,int n){
          for (;n>0;p++)
            if (*p==0) {
                n--;
            }
            return p;
    }
    

    To get rid of the error:

    int main(int argc, char *argv[])
    {
        // cast the string which is of the type const char* to the
        // type of the defined variable(char*) will remove your warning.   
        char *p= (char*) "dedamiwa";
        int n=4;
        cout<<skip(p,n)<<endl;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to determine, based on the result of this call, if it was
I'm trying to determine if the user is using 24 hour or 12 hour
I am trying to determine how to structure the code of a simple android
I have this little bit of code: using System; using System.Web.Mvc; public class SecureFilter
I am trying to determine if my code is running on an iPhone or
Possible Duplicates: Why is this C code buggy? Problem with EOF when determine stream
Trying to determine if it is possible to bind the SelectedValue of a ComboBox
Am trying to determine the best way to persist information from an originating email,
I trying to determine display vertical size of my Blackberry Storm 2. I know,
I'm trying to determine if there's a way in Visual Basic 2008 (Express edition

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.