elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


  Mostrar Mensajes
Páginas: 1 ... 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 [354] 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 ... 401
3531  Programación / Programación C/C++ / Re: Pedido o ayuda ARCHIVOS/REGISTROS en: 10 Febrero 2014, 18:40 pm
Puedes ir leyendo el archivo, e ir escribiéndolo en otro archivo. Cuando des con la línea, simplemente, no la escribes.
3532  Programación / Desarrollo Web / Re: en: 10 Febrero 2014, 08:17 am
Todo es probar. Miraré hoy cuando pueda que cabeceras son imprescindibles :p

Enviado desde mi ST21i mediante Tapatalk
3533  Programación / Desarrollo Web / Re: Como ver un request HTTP? en: 9 Febrero 2014, 16:36 pm
Perdon por lo que dije de la variable, me confundí :3

Cogí con WPE los paquetes del envío de una imagen, y esta fue la cabecera,si te sirve:

Código:
POST /XXX.php HTTP/1.1
User-Agent: XXXXXXXXXX
Host: XXXX.es
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: es,en;q=0.9,es-ES;q=0.8
Accept-Encoding: gzip, deflate
Referer: http://XXX/XXX.html
Connection: Keep-Alive
Content-Length: 170457
Content-Type: multipart/form-data; boundary=----------HCnR65lo15kSYiPLN9Rgw9....------------HCnR65lo15kSYiPLN9Rgw9
Content-Disposition: form-data; name="file"; filename="XXXXX.png"
Content-Type: image/png

<AQUI LA IMAGEN>

Muchos campos de la cabecera son innecesarios, pero bueno, te la pongo entera.

Y bueno, como dijo jednak, la imágen abrela desde el programa, y ve enviando su contenido, no la abras como txt y la copies ni nada así jaja

PD: Si la abres, abrela como BINARIO.
3534  Programación / Desarrollo Web / Re: Como ver un request HTTP? en: 9 Febrero 2014, 14:22 pm
Mira que cabecera envía el navegador al enviar una imágen, por ejemplo.

PD: Una imagen, se le envía con una varible en el method POST:

Código:
\r\n\r\n
var=<los datos de la imagen>
3535  Programación / Desarrollo Web / Re: Como ver un request HTTP? en: 9 Febrero 2014, 01:33 am
Citar
POST /Proyectos/Uploads/uploader.php HTTP/1.1\nhost: localhost

Tengo entendido que no importa en algunos servidores enviarles \n sin el \r, pero podrías probar:

Citar
POST /Proyectos/Uploads/uploader.php HTTP/1.1\r\nHost: localhost

EDITO: Si no te va, prueba acambiar localhost por tu IP local.
3536  Programación / Desarrollo Web / Re: Como ver un request HTTP? en: 9 Febrero 2014, 00:17 am
Citar
"Content-Length: 3024\r\n"

Después de el último \r\n, envia los 3024 bytes, y listo.
3537  Programación / Programación C/C++ / Re: Programa que identifique que tipo de dato se introduce C++ en: 8 Febrero 2014, 21:49 pm
Se puede hacer, pero tendrías que comprobar la cadena a ver si se puede convertir. Despues de saber si se puede convertir, tendrías que convertirla.

Aquí te pongo un par de códigos:

Saber a que tipos de dato se puede transformar:
Código
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. enum type{
  6.    /**    TYPES    **/
  7.    type_bool     = 0b000000000001,
  8.    type_char     = 0b000000000010,
  9.    type_uchar    = 0b000000000100,
  10.    type_short    = 0b000000001000,
  11.    type_ushort   = 0b000000010000,
  12.    type_int      = 0b000000100000,
  13.    type_uint     = 0b000001000000,
  14.    type_llong    = 0b000010000000,
  15.    type_ullong   = 0b000100000000,
  16.    type_float    = 0b001000000000,
  17.    type_double   = 0b010000000000,
  18.    type_ldouble  = 0b100000000000,
  19.  
  20.    /**    OTHER    **/
  21.    type_signed   = 0b111010101011,
  22.    type_unsigned = 0b000101010100,
  23.    type_all      = 0b111111111111
  24. };
  25.  
  26. bool allNumeric(string s){
  27.    for(int i=0; i<s.size(); i++)
  28.        if(s[i]<48 || s[i]>57)
  29.        return false;
  30.    return true;
  31. }
  32.  
  33. bool minorEqual(string a, string b){
  34.    if(a.size()<b.size()) return true;
  35.    if(a.size()>b.size()) return false;
  36.    if(a==b) return true;
  37.    for(int i=0; i<a.size(); i++)
  38.        if(a[i]<b[i]) return true;
  39.        else if(a[i]>b[i]) return false;
  40.    return true;
  41. }
  42.  
  43. int typeOf(string s){
  44.    if(s=="") return 0;
  45.    int type = 0;
  46.    bool sign = false;
  47.    /** BOOL **/
  48.    if((s.size()==1 && (s[0]=='0'||s[0]=='1'))||(s.size()==4 &&s.substr(0, 4)=="true")||(s.size()==5 &&s.substr(0, 5)=="false"))
  49.        type+=type_bool;
  50.  
  51.    /** CHAR && UCHAR **/
  52.    if(s.size()==1)
  53.        type+=type_char+type_uchar;
  54.    else{
  55.        if(s[0]=='-')
  56.            sign=true;
  57.        if(s.size()<4+sign && allNumeric(s.substr(sign, s.size()))){
  58.            if(sign){
  59.                if(minorEqual(s.substr(1, s.size()), "128"))
  60.                    type+=type_char;
  61.            }else{
  62.                if(minorEqual(s.substr(0, s.size()), "127"))
  63.                    type+=type_char;
  64.                if(minorEqual(s.substr(0, s.size()), "255"))
  65.                    type+=type_uchar;
  66.            }
  67.        }
  68.    }
  69.  
  70.    /** SHORT && USHORT **/
  71.    if(s[0]=='-')
  72.        sign=true;
  73.    if(allNumeric(s.substr(sign, s.size()))){
  74.        if(sign){
  75.            if(minorEqual(s.substr(1, s.size()), "32768"))
  76.                type+=type_short;
  77.        }else{
  78.            if(minorEqual(s.substr(0, s.size()), "32767"))
  79.                type+=type_short;
  80.            if(minorEqual(s.substr(0, s.size()), "65535"))
  81.                type+=type_ushort;
  82.        }
  83.    }
  84.  
  85.    /** INT && UINT **/
  86.    if(s[0]=='-')
  87.        sign=true;
  88.    if(allNumeric(s.substr(sign, s.size()))){
  89.        if(sign){
  90.            if(minorEqual(s.substr(1, s.size()), "2147483648"))
  91.                type+=type_int;
  92.        }else{
  93.            if(minorEqual(s.substr(0, s.size()), "2147483647"))
  94.                type+=type_int;
  95.            if(minorEqual(s.substr(0, s.size()), "4294967295"))
  96.                type+=type_uint;
  97.        }
  98.    }
  99.  
  100.    /** LONG && ULONG **/
  101.    if(s[0]=='-')
  102.        sign=true;
  103.    if(allNumeric(s.substr(sign, s.size()))){
  104.        if(sign){
  105.            if(minorEqual(s.substr(1, s.size()), "9223372036854775808"))
  106.                type+=type_llong;
  107.        }else{
  108.            if(minorEqual(s.substr(0, s.size()), "9223372036854775807"))
  109.                type+=type_llong;
  110.            if(minorEqual(s.substr(0, s.size()), "18446744073709551615"))
  111.                type+=type_ullong;
  112.        }
  113.    }
  114.    double b=atof(s.c_str());
  115.    float a=(float)b;
  116.    bool is=false;
  117.    if(b==0.0 && (s=="0"||s=="0.0")){
  118.        type+=type_float+type_double;
  119.    }else if(b!=0.0){
  120.        type+=type_double;
  121.        if(a==b)
  122.            type+=type_float;
  123.    }
  124.    return type;
  125. }
  126.  
  127. int main(){
  128.    string s;
  129.    getline(cin, s);
  130.    if(typeOf(s)&type_int)
  131.        cout << "Se puede transformar en un entero (signed)." << endl;
  132.    cin.get();
  133.    return 0;
  134. }


Ejemplo de como transformar string a int:
Código
  1. int potencia(int n, int b){
  2.   int temp=1;
  3.   for(int i=0;i<b;i++) temp=temp*n;
  4.   return temp;
  5. }
  6.  
  7. int parseString(string s){
  8. string a;
  9. int num = 0;
  10. for(int i=s.length()-1;i>=0;i--){
  11.  if(!((int)s[i]>=48 && (int)s[i]<=57)) return 0;
  12.  num+=((int)s[i]-48)*(potencia(10, s.length()-i-1));
  13. }
  14. return num;
  15. }

Bueno, aún no acabé con las funciones para transformar de string a numérico.
Igualmente, puedes usar las funciones atol(string) Retorna un LONG, atof() Retorna un DOUBLE, atoi() Retorna un INT


EDITO: Me olvidé decir, que el FLOAT, de la función typeOf(string), no funciona. Pero funciona para double.
3538  Programación / Programación C/C++ / Re: Programa que identifique que tipo de dato se introduce C++ en: 8 Febrero 2014, 16:08 pm
Me pongo a esto:

Código
  1. enum type{
  2.    type_signed = 1,
  3.    type_bool = 2,
  4.    type_int = 4,
  5.    type_short = 8,
  6.    type_float = 16,
  7.    type_double = 32,
  8.    type_char = 64
  9.    /* ... */
  10. }
  11.  
  12. int typeOf(string s){
  13.    /** Esto retornará un entero compuesto de los números que pueda ser.
  14.           Si es "12", por ejemplo, puede ser short, int, float, double y char. Entonces, retornaría: 4+8+16+32+64. (Puede ser más tipos, pero aun estoy empezando el enum jaja **/
  15. }
Luego, la salida de typeOf se parsearía así:
Código
  1. if(typeOf(str)&type_double) double d = parse<double>(str);
la función parse podría tener un template para retornar el tipo indicado xD


EDITO: Como es diferente el tamaño de un signed al de un unsigned (el tamaño máximo), quitaré el type_signed, y pondré type_uchar, type_uint etc etc

EDITO 2: Finalmente:
Código
  1. enum type{
  2.    /**    SIGNED TYPES    **/
  3.    type_bool     = 0b0000000000000001,
  4.    type_char     = 0b0000000000000010,
  5.    type_short    = 0b0000000000000100,
  6.    type_int      = 0b0000000000001000,
  7.    type_llong    = 0b0000000000010000,
  8.    type_float    = 0b0000000000100000,
  9.    type_double   = 0b0000000001000000,
  10.    type_ldouble  = 0b0000000010000000,
  11.  
  12.    /**    UNSIGNED TYPES    **/
  13.    type_ubool    = 0b0000000100000000,
  14.    type_uchar    = 0b0000001000000000,
  15.    type_ushort   = 0b0000010000000000,
  16.    type_uint     = 0b0000100000000000,
  17.    type_ullong   = 0b0001000000000000,
  18.    type_ufloat   = 0b0010000000000000,
  19.    type_udouble  = 0b0100000000000000,
  20.    type_uldouble = 0b1000000000000000,
  21.  
  22.    /**    OTHER    **/
  23.    type_signed   = 0b0000000011111111,
  24.    type_unsigned = 0b1111111100000000,
  25.    type_all      = 0b1111111111111111
  26. };


RE-EDITO: Ahora me dió pereza poner toodos los "if" para comprobar cada tipo jaja. Si alguien se anima, aunque sea para 1 tipo solo, que postée :3
3539  Programación / Programación C/C++ / Re: Programa que identifique que tipo de dato se introduce C++ en: 8 Febrero 2014, 15:58 pm
Me gusta la idea de yoel_alejandro.
Pero, aprobechendo que el tipo de retorno de "isNumeric" es int, podría retornarse un número según el tipo de dato. (float, double, int, long long int, etc)

Sería una función muy útil.
3540  Programación / Programación General / Re: Autoclicker En NanoSegundos en: 8 Febrero 2014, 14:52 pm
No es tan rápido un ordenador para dar click cada nanosegundo.
Páginas: 1 ... 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 [354] 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 ... 401
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines