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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:40:42+00:00 2026-05-29T06:40:42+00:00

I got a compiler error: main.cpp|59|error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]| The

  • 0

I got a compiler error:

main.cpp|59|error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive]|

The offending line is

int *pComienzo = vector, *pFinal = vector[nElementos-1];

Why there is an error? Can someone help me?

Below is my code:

#include <iostream>
#include <ctype.h>

using namespace std;
const unsigned short int MAX_VAL = 10;

int LongitudCadena(char*);

int BuscarCaracter(char *cadena, char caracter);

void Ordenar(int *vector, int nElementos, bool ascendente);

int main()
{
    char *cadena = "asdasd";

    cout << LongitudCadena(cadena) << endl;

    cout << BuscarCaracter(cadena, 'a') << endl;

    int iArray[] = {5,4,3,2,1};

    Ordenar(iArray, 5, 1);

    cout << iArray << endl;

    return 0;
}

int LongitudCadena(char *cadena)
{
    char *c = cadena;
    for(int i = 0; i < MAX_VAL; i++)
    {
        if (c[i] == 0) break;
        cadena++;
    }

    return  cadena - c;
}

int BuscarCaracter(char * cadena, char caracter)
{
    char *pCadena = cadena;
    for (int i = 0; i < MAX_VAL; i++)
    {
        pCadena++;
        if (toupper(cadena[i]) == toupper(caracter))
        return pCadena- cadena;
    }

    return -1;
}

void Ordenar(int *vector, int nElementos, bool ascendente)
{


    int *pComienzo = vector, *pFinal = vector[nElementos-1];

    if (ascendente)
    {
        for (int i = 0; i < nElementos; i++)
        {
            for (; pComienzo < pFinal; pComienzo++, pFinal--)
            {
                if (*pComienzo > *pFinal)
                {
                    *pComienzo += *pFinal;
                    *pFinal -= *pComienzo;
                    *pComienzo -= *pFinal;
                }
            }
        }
    }
}

I’m learning…

  • 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-29T06:40:43+00:00Added an answer on May 29, 2026 at 6:40 am

    Your error is in this line:

    int *pComienzo = vector, *pFinal = vector[nElementos-1];
    

    The reason for this is that vector is an int*, but vector[nElementos - 1] is a regular int. Thus the declaration

    int *pFinal = vector[nElementos - 1];
    

    is trying to assign the integer value at the last index of vector to the pointer pFinal, hence the compiler error.

    To fix this, you may want to do either

    int *pFinal = &vector[nElementos - 1];
    

    which makes pFinal point to the last element of vector, or

    int *pFinal = vector + (nElementos - 1);
    

    which accomplishes the same thing using pointer arithmetic.

    That said, since you’re working in C++, why not use the provided std::vector type and avoid working with pointers altogether?

    Hope this helps!

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

Sidebar

Related Questions

I've got a compiler error but I can't figure out why. the .hpp: #ifndef
I got this compiler error: You cannot reduce the visibility of a inherited method.
I've got this code to port from windows to linux. template<class T, int Size>
I tried a simple example with boost::function. However I got the compiler error said:
I've got a function that should read from file line by line, the reading
Say you've got the following simple main.cpp file: #include <cstdlib> #include <iostream> #include <fstream>
I got this error when I tried to compile an application that includes the
When I compiled the sample codes of C++, I got following info: c++ excxx_example_database_read.cpp
Possible Duplicate: Convert some code from C++ to C I've got some code that
I switched from Visual Studio to Code::Blocks yesterday, and just had some strange compiler

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.