SDL_SetRenderTarget inside a loop



In my application, i now use SDL_SetRenderTarget for my objects.
I migrate old code to the new one that use SDL_SetRenderTarget but I have an issue:

This code works when using i as int but not i inside a loop ? :disappointed_relieved:

//for ( size_t i = 0; i < NOMBRSERVERAPP; i++ ) // for every objects
int i = 2;

  FileName.append(pCadreFichImage[i]);                                   // file name
  SDL_Surface *PntSurfSrvr = IMG_Load(FileName.c_str( ) );              // loading
  int SizW = PntSurfSrvr->w;
  int SizH = PntSurfSrvr->h;
  SDL_Texture *PntTextureTemp = SDL_CreateTextureFromSurface( gRender, PntSurfSrvr );
  pTbPtImgSrvTxur[i] = SDL_CreateTexture(gRender, SDL_PIXELFORMAT_RGBA8888,SDL_TEXTUREACCESS_TARGET,SizW,SizH); 

  SDL_SetTextureBlendMode( pTbPtImgSrvTxur[i], SDL_BLENDMODE_BLEND );      // transParence
  SDL_SetRenderTarget( gRender, pTbPtImgSrvTxur[i] );                       //RENDERING
  SDL_RenderCopy( gRender, PntTextureTemp, NULL, NULL );                  // copy
  SDL_SetRenderTarget( gRender, NULL );                                  // end render Texture
  SDL_DestroyTexture( PntTextureTemp );                                  // free texture

  SDL_FreeSurface( PntSurfSrvr );                                    //  free  surface


Could you please help me?
The object is well displayed when i don’t use the loop:
When I use a texture pointer instead of a table of texture pointers
Is there anything I forgot to write?
Thanks :sunglasses: