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

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


  Mostrar Mensajes
Páginas: 1 ... 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [27] 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 ... 59
261  Programación / Programación C/C++ / Re: Problema con sockets WinSock2 en: 25 Septiembre 2011, 19:39 pm
Cual error te tira?
262  Programación / Programación C/C++ / Re: Problema con sockets WinSock2 en: 25 Septiembre 2011, 19:04 pm
Nunca le asignas a Cliente lo que devuelve la función socket()...
Código
  1. Cliente = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  2.  
263  Programación / Programación C/C++ / Re: duda sobre strstr en c++ (WinApi) en: 23 Septiembre 2011, 18:21 pm
Bueno supongo que esto pasa porque strlen() devuelve unsigned int y lo estoy asignando a variables tipo int... Aquí lo modifiqué:

Código
  1. char *strreplace(const char * str, const char * find, const char * replace){
  2. unsigned int i,j,k,pos, val, size, oldsize, cont;
  3. unsigned int bytes = strlen(str)-strlen(find)+strlen(replace);
  4. int flag;
  5.  
  6. char * nstr = (char*)malloc(bytes+1);
  7. memset(nstr, 0, bytes+1);
  8.  
  9. for(i = 0; i <= strlen(str)-strlen(find); i++){
  10. flag = 1;
  11. val = i;
  12. k = 0;
  13. // unsigned int z = (i+strlen(find)-1);
  14. for(j=i; j<=(i+strlen(find)-1); j++){
  15. if(find[k] != str[j])
  16. flag = 0;
  17. k++;
  18. }
  19.  
  20. if(flag != 0)
  21. pos = val;
  22. }
  23.  
  24.    size = pos + strlen(replace) - 1;
  25.    oldsize = pos + strlen(find);
  26. cont = 0;
  27. j = 0;
  28.  
  29.    for(i=0;i<=bytes-1;i++){
  30.        if(i>=pos && i<=size){
  31.            nstr[i] = replace[cont];
  32.            cont++;
  33.            if(i==size)
  34.                j=oldsize;
  35.        } else {
  36.            nstr[i] = str[j];
  37.            j++;
  38.        }
  39.    }
  40.  
  41. return nstr;
  42. }
264  Programación / Programación C/C++ / Re: duda sobre strstr en c++ (WinApi) en: 22 Septiembre 2011, 20:29 pm
Código
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. char *strreplace(const char * str, const char * find, const char * replace){
  6. int i,j,k, flag, pos = -1;
  7. int bytes = strlen(str)-strlen(find)+strlen(replace);
  8. char * nstr = (char*)malloc(bytes+1);
  9. memset(nstr, 0, bytes+1);
  10.  
  11. for(i = 0; i <= strlen(str)-strlen(find); i++){
  12. flag = i;
  13. k = 0;
  14. for(j=i; j<=(i+strlen(find)-1); j++){
  15. if(find[k] != str[j])
  16. flag = -1;
  17. k++;
  18. }
  19.  
  20. if(flag != -1)
  21. pos = flag;
  22. }
  23.  
  24.    int size = pos + strlen(replace) - 1;
  25.    int oldsize = pos + strlen(find);
  26. int cont = 0;
  27. j = 0;
  28.  
  29.    for(i=0;i<=bytes-1;i++){
  30.        if(i>=pos && i<=size){
  31.            nstr[i] = replace[cont];
  32.            cont++;
  33.            if(i==size)
  34.                j=oldsize;
  35.        } else {
  36.            nstr[i] = str[j];
  37.            j++;
  38.        }
  39.    }
  40.  
  41. return nstr;
  42. }
  43.  
  44. int main(){
  45. char * reemplazo = strreplace("Texto & texto", "&", "&&");
  46. printf("%s\n" ,reemplazo);
  47. free(reemplazo);
  48.  
  49. return 0;
  50. }
  51.  

Fíjate si mi función de strreplace te funciona...
265  Programación / Programación C/C++ / Re: duda sobre strstr en c++ (WinApi) en: 22 Septiembre 2011, 19:47 pm
Podrías hacer lo siguiente dejarlo como lo tenías en un principio y hacer una función strreplace como la de php no se si sabes como es, y reemplazas el & por && cuando vayas a asignarle el texto al menú y listo.
266  Programación / Programación C/C++ / Re: Problema con control STATIC en: 22 Septiembre 2011, 18:14 pm
SetWindowLongPtr y GWLP_WNDPROC para que "interceptes" los mensajes del botón.

Citar
Return value

Type: LONG_PTR

If the function succeeds, the return value is the previous value of the specified offset.
267  Programación / Programación C/C++ / Re: duda sobre strstr en c++ (WinApi) en: 22 Septiembre 2011, 18:11 pm
A ver si entiendo bien tu resultado debería ser el siguiente:

"aaaa & bbb"

y no:

"aaaa &bbb"
268  Programación / Programación C/C++ / Re: algo basico super basico pero que no me sale en: 22 Septiembre 2011, 01:54 am
Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int arreglo[3][3], i, j, fila, columna;
  5.  
  6. int main(){
  7. fila = 0;
  8. columna = 0;
  9.  
  10. for(i = 0; i < 3; i++){
  11. for(j=0;j<3;j++){
  12. scanf("%d", &arreglo[i][j]);
  13. }
  14. }
  15.  
  16. for(i = 0; i < 3; i++){
  17. for(j=0;j<3;j++){
  18. fila += arreglo[j][i];
  19. columna += arreglo[i][j];
  20. }
  21. }
  22.  
  23. printf("Suma de filas: %d\n", fila);
  24. printf("Suma de columnas: %d\n", columna);
  25.  
  26. return 0;
  27. }
  28.  
269  Programación / Programación C/C++ / Re: Problema con control STATIC en: 22 Septiembre 2011, 01:01 am
Pero si la imagen no es transparente no se va a mostrar el color que estas asignando... Algo debe estar mal.
270  Programación / Programación C/C++ / Re: algo basico super basico pero que no me sale en: 21 Septiembre 2011, 21:45 pm
Que has intentado? Pon tu código para ver que tienes mal.
Páginas: 1 ... 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 [27] 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 ... 59
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines