- ESTO ES UNA PRUEBA
DE COMO SE DEBE
IMPRIMIR EN LA VISTA
ES URGENTE AMIGOS LES AGRADESCO ANTICIPADAMENTE.
![]() |
![]() |
|
Moderador: latindeveloper

const int MAXPAL = 30;
class CObtenerPalabra
{
char *buffer, palabra[MAXPAL];
char *p_actual;
private:
inline int IsSpace (int i) { return i == ' ' /*|| i == '\n' || i == '\t'*/; }
public:
CObtenerPalabra (char* texto)
{
buffer = new char[strlen (texto) + 1];
strcpy (buffer, texto);
for (p_actual = buffer; *p_actual && IsSpace(*p_actual); //isspace(*p_actual);
p_actual++);
}
~CObtenerPalabra () { delete[] buffer; }
char* SiguientePalabra ()
{
if (*p_actual == '\0')
return NULL;
for (int i = 0; *p_actual && !IsSpace(*p_actual) && i < MAXPAL; i++)
palabra[i] = *p_actual++;
palabra[i] = '\0';
while (*p_actual && IsSpace(*p_actual))
p_actual++;
return palabra;
}
void Reset ()
{
for (p_actual = buffer; *p_actual && IsSpace(*p_actual); p_actual++);
}
};LPTSTR lpsz = new TCHAR[m_Frase.GetLength()+1];
_tcscpy(lpsz, m_Frase);
CObtenerPalabra op (lpsz);
int maximo = 40, count = 0,tt=0;
char* p;
// muestra el texto con un máximo de 24 caracteres
while (1)
{
if ((p = op.SiguientePalabra ()) == NULL)
break;
if ((count + strlen (p) + 1) <= maximo)
{
pDC->TextOut(100+(count*10),100+(tt*15),p);
count += strlen (p) + 1;
} else
{
tt++;
pDC->TextOut(100,100+(tt*15),p);
count = strlen (p) + 1;
}
}
Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 2 invitados