Hi,

here below i have a code.

It reads a line from a text file and then it takes that line to other function (DescargarUrl()).

"DescargarUrl()" prints the line that was readen previously from the text file.

The problem:

depending in the order of the lines 94 y 95 it prints correctly the line that was readen from the text file or not. why?

I mean:

this prints ok the line
Code:
	line 94: printf("DescargarUrl: %s \n", Url);	
	line 95: CInternetSession SesionInternet;
this doesn't print ok the line:
Code:
        line 94: CInternetSession SesionInternet; 
        line 95: printf("DescargarUrl: %s \n", Url);
Code:
// p4_OK.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "p4_OK.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

int Principal();

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else
	{
		
		Principal();
	}

	return nRetCode;
}

char * ExtraerParametros()

{

	
   char nombre[100]="C:\\Archivos de programa\\Microsoft Visual Studio\\MyProjects\\p3\\ordenes.txt";
   FILE *fichero;
   

   fichero = fopen( nombre, "r" );

	
	char cad[3]="#\n";
	
	char linea_ord[1000];

	fread( linea_ord, sizeof(char), 1000, fichero );

	   
	printf ("Los parametros de la linea de comandos de ordenes.txt son los siguientes: \n\n");

	

	printf ("- Primera URL: ");
	char *ptr;

	ptr = strtok(linea_ord , cad );    // Primera llamada => Primer token
	printf( "%s\n", ptr );

	
	char * ptr2;
	ptr2=ptr;

	
	printf("- Segunda URL (archivos a descargar): ");
	ptr = strtok( NULL, cad );
	printf( "%s\n", ptr );
	


	fclose(fichero);

	return ptr2;

}



char * DescargarUrl(char * Url, int * Error, long * Tamanyo)
{


	printf("DescargarUrl: %s \n", Url);	
	CInternetSession SesionInternet; // Abrir una sesion de Internet


	
	char *a=NULL;
	
	return a;

}


int Principal()
{

   char nombre_img[100]="C:\\Archivos de programa\\Microsoft Visual Studio\\MyProjects\\p3\\imagen.jpg";
   FILE *fichero_img;
   

   fichero_img = fopen( nombre_img, "w+" );
   

	char * URL1;

	char * Fichero = NULL;

	int Error = 0;
	long Tamanyo = 0;

	URL1 = ExtraerParametros();
	

	Fichero = DescargarUrl(URL1, &Error, &Tamanyo);

	return 0;

}
Regards

Javi