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

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


  Mostrar Mensajes
Páginas: 1 ... 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 43 44 45 46 47 ... 331
311  Programación / Programación Visual Basic / Re: [VB6] &H20? Explicación? en: 11 Agosto 2012, 07:35 am
Código
  1. If (A And &H20) Then Exit Function
  2. If (C And &H8000) Then Exit Function
  3. If (B And &H8) Then
  4. etc...

En ese caso se le llaman MASCARAS DE BITS es decir Filtra TODOS los bits 1 que concuerden (tal cual el ejemplo de @79137913) con que solo sea un numero distinto de 0 se tratara como un valor TRUE PERO si la mascara no retorna un numero distinto cero, es decir, nos retornara el 0 se toma la expresión como FALSE.

* OJO esto en caso de que estén en sentencias de un if then, while, etc...

Existen otros casos como estos:

E = (A and 5 or 10) xor B

en este tipo de expresión NO IMPORTA DONDE SE UBIQUEN inclusive en los if then se toman como operaciones binarias es decir operaciones con bits (revisa los post de arriba).

Dulces Lunas!¡.
312  Programación / Programación Visual Basic / Re: Ayuda... Repetir funcion hasta el final del archivo en: 11 Agosto 2012, 07:09 am

Chunk = Text1.Text
Bit1 = 12
Bit2 = 16
bChar = Mid$(Chunk, Bit1, 1)
Mid$(Chunk, Bit1, 1) = Mid$(Chunk, Bit2, 1)
Mid$(Chunk, Bit2, 1) = bChar
Text2.Text = Chunk


Con mid$() NO vas a trabajar con bits de manera directa, necesitas usar las operaciones auxiliares de equivalencia... ya que o trabajas con bits o trabajas con bytes ambos son distintos... y me da la impresion que te refieres a bytes y no a bits...

usando el array de bytes puedes hacer un cambio de bytes muy simple como este (NO ES LO QUE PIDES O ESO CREO... ya que no se te entendió realmente la idea):

Código
  1. '12 al 2
  2. '15 al 4
  3. '9 al 13
  4. '5 al 10
  5. '11al 8
  6. '3 al 7
  7. '1 al 14
  8. '16 al 6
  9. Const sFileName As String = "c:\alcaeda.txt"
  10. Dim ff As Integer
  11. Dim d As Long
  12. Dim array_data() As Byte
  13.  
  14.    ff = FreeFile()
  15.    Open sFileName For Binary Access Read As ff
  16.        If (LOF(ff) > 0) Then
  17.            ReDim array_data(0 To LOF(ff))
  18.            Get ff, , array_data
  19.            d = 0
  20.            While (d < LOF(ff))
  21.                bSwap array_data(12 + d), array_data(2 + d)
  22.                bSwap array_data(15 + d), array_data(4 + d)
  23.                bSwap array_data(9 + d), array_data(13 + d)
  24.                bSwap array_data(5 + d), array_data(10 + d)
  25.                bSwap array_data(11 + d), array_data(8 + d)
  26.                bSwap array_data(3 + d), array_data(7 + d)
  27.                bSwap array_data(1 + d), array_data(14 + d)
  28.                bSwap array_data(16 + d), array_data(6 + d)
  29.                d = (d + 8)
  30.            Wend
  31.        End If
  32.    Close ff
  33.  

La función bSwap() la encuentras aquí:
Recopilacion de Funciones con operaciones Binarias.

NOTA: Si vas a PROCESAR un archivo sin importarte que sea o no legible para un ser humano es mejor usar un array de bytes ya que mid$() es para strings y este ultimo tipo esta orientado para otros tipos de datos pero igual se puede ocuper pero en lo personal es menos recomendable...

Dulces Lunas!¡.
313  Programación / Programación C/C++ / Re: Tamaño bytes para una estructura en: 11 Agosto 2012, 01:35 am
También lo puedes dejar de esta manera:

Código
  1. fichaPersona Alumnos[20];
  2. memset(Alumnos, 0, sizeof Alumnos);

Código
  1. sizeof Alumnos
Es una abreviación de:
Código
  1. sizeof *Alumnos * 20
Aun que una equivalencia es usar
Código
  1. sizeof(fichaPersona) * 20
.

Dulces Lunas!¡.
314  Programación / Programación C/C++ / Re: [DUDA] añadir espacios al utilizar la función strcat en: 10 Agosto 2012, 23:19 pm
BlackZeroX (Astaroth) Comprendo, tienes razon, luego se producirian errores logicos, pero mira esta seria una buena correccion !!

Código
  1. printf("Named Server: ");
  2.    gets(ip);
  3.  
  4.    if(strlen(ip)>=15) //comprobamos que nuestro vector no este al limite de caracteres
  5.    {return 1;} //tambien puedes devolver un mensaje avisando de la falta de espacio
  6.  

Estas errado, lo mejor es usar una función QUE limite esto... es por ello que en el código que yo publique use fgets(), checa-lo...

Dulces Lunas!¡.
315  Programación / Programación C/C++ / Re: pasar datos de una cola dinámica a otra cola... en: 10 Agosto 2012, 10:01 am
mira tengo este codigo:
Código:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
   struct Node* first = NULL;
   struct Node* last = NULL;
   struct Node* temporal = NULL;
   struct Node2* first2 = NULL;
   struct Node2* last2 = NULL;
   struct Node2* temporal2 = NULL;
struct Node{
   int data;
   char nombre;
   int tiempo;
   int quant;
   struct Node* next;
};

struct Node2{
   int data2;
   char nombre2;
   int tiempo2;
   int quant2;
   struct Node2* next2;
};

struct Node* newNode(int data,char nombre, int tiempo,int quant){
   struct Node* New = (struct Node*)malloc(sizeof(struct Node));
   New->data = data;
   New->nombre = nombre;
   New->tiempo = tiempo;
   New->quant = quant;
   New->next = NULL;
   return New;
}

struct Node2* newNode2(int data2,char nombre2, int tiempo2,int quant2){
   struct Node2* New = (struct Node2*)malloc(sizeof(struct Node2));
   New->data2 = data2;
   New->nombre2 = nombre2;
   New->tiempo2 = tiempo2;
   New->quant2 = quant2;
   New->next2 = NULL;
   return New;
}

void agregar(struct Node** first, struct Node** last, int data, char nombre,int tiempo,int quant){
   if(*first == NULL && *last == NULL){
      *first = newNode(data,nombre,tiempo,quant);
      *last = *first;
   }
   else{
      (*last)->next = newNode(data,nombre,tiempo,quant);
      (*last) = (*last)->next;
   }
}
void agregar2(struct Node2** first2, struct Node2** last2, int data2, char nombre2,int tiempo2,int quant2){
   if(*first2 == NULL && *last2 == NULL){
      *first2 = newNode2(data2,nombre2,tiempo2,quant2);
      *last2 = *first2;
   }
   else{
      (*last2)->next2 = newNode2(data2,nombre2,tiempo2,quant2);
      (*last2) = (*last2)->next2;
   }
}

struct Node* borrar(struct Node** first, struct Node** last){
   struct Node* temporal;
   if(*first == NULL && *last == NULL){
      printf("Cola está vacía...\n\n");
      return NULL;
   }
   else if((*first)->next == NULL && (*last)->next == NULL){
      printf("Cola contiene un único elemento...\n\n");
      temporal = *first;
      *first = NULL;
      *last = NULL;
      return temporal;
   }
   else{
      printf("Cola contiene más de un elemento...\n\n");
      temporal = *first;
      *first = (*first)->next;
      return temporal;
   }
}

void mostrar(struct Node* agre){

   //struct Node* temporal = NULL;
   printf("\n");
   //while(agre != NULL){
      printf("%d ", agre->data);
      int id=agre->data;
      char n=agre->nombre;
      int t=agre->tiempo;
      int q=agre->quant;
      cout<<agre->nombre<<" ";      
      printf("%d ", agre->tiempo);
      cout<<agre->quant<<" ";
        if(t > q){
for(int i = (time(NULL) + q); time(NULL) != i; time(NULL));
t=t-q;
cout<<t;
borrar(&first,&last);
agregar(&first, &last, id,n,t,q);
}
else{
for(int i = (time(NULL) + t); time(NULL) != i; time(NULL));
t=t-t;
cout<<t;
borrar(&first,&last);
agregar2(&first2, &last2, id,n,t,q);
}

/*if((temporal = borrar(&first, &last)) != NULL){
               printf("Dequeued value was: %d\n\n", temporal->data);
               free(temporal);
            }*/
            
 /*agre->tiempo = t;
 system("clear");
 cout<<endl<<endl;
 printf("%d ", agre->data);
 cout<<agre->nombre<<" ";
 printf("%d ", agre->tiempo);
          cout<<agre->quant<<" ";*/
 
      //agre = agre->next;
   //}
   printf("\n\n");
}

void mostrar2(struct Node* agre){
while(agre != NULL){
printf("\n");
printf("%d ", agre->data);
      cout<<agre->nombre<<" ";      
      printf("%d ", agre->tiempo);
      cout<<agre->quant<<" ";
      agre = agre->next;
  }
      printf("\n\n");
}
void mostrar3(struct Node* agre,struct Node2* agre2){
while(agre != NULL){
printf("\n");
printf("%d ", agre->data);
      cout<<agre->nombre<<" ";      
      printf("%d ", agre->tiempo);
      cout<<agre->quant<<" ";
      agre = agre->next;
  }
      printf("\n\n");
      while(agre2 != NULL){
printf("\n");
printf("%d ", agre2->data2);
      cout<<agre2->nombre2<<" ";      
      printf("%d ", agre2->tiempo2);
      cout<<agre2->quant2<<" ";
      agre2 = agre2->next2;
  }
      printf("\n\n");
}

int main(){
   //struct Node* first = NULL;
   //struct Node* last = NULL;
   //struct Node* temporal = NULL;
   int data;
   char nombre;
   int tiempo;
   int quant;
   char option = '1';
  
   while(option != 'e' && option != 'E'){
      printf("1)Agregar\n");
      printf("2)Borrar\n");
      printf("3)simular\n");
      printf("4)mostrar\n");
      printf("5)mostrar ambas\n");
      printf("e)Exit ");
      scanf("%c", &option);
      getchar();
      
      switch(option){
         case '1':
            printf("Ingrese ID (int): ");
            scanf("%d", &data);
            cout<<"Ingrese el nombre (int): ";
            cin>>nombre;
            printf("Ingrese el tiempo (int): ");
            scanf("%d", &tiempo);
            cout<<"Ingrese Quantum: ";
            cin>>quant;
            getchar();
            agregar(&first, &last, data,nombre,tiempo,quant);
            printf("\n");
         break;
        
         case '2':
            if((temporal = borrar(&first, &last)) != NULL){
               printf("Valor fue quitado de la cola: %d\n\n", temporal->data);
               free(temporal);
            }
            else printf("No hay ningún valor en la cola...\n\n");
         break;
        
         case '3':
            mostrar(first);
         break;
        
         case '4':
mostrar2(first);
break;
case '5':
mostrar3(first,first2);
break;
        
         case 'e': case 'E':break;
        
         default: printf("No es una opción...\n\n");
      }
   }
  
   return 0;
}


el ingreso de los datos lo hago manual, pero ahora ya no lo quiero hacer manual sino que los datos los obtenga apartir del txt que me van a dar..

Código:
crear proceso(1,uno,5,6)
crear proceso(2,dos,4,5)


Gracias por la ayuda

Te recomiendo usar el código del enlace que te deje anteriormente, con algunas modificaciones a la estructura y al codigo.

Por ejemplo en la estructura (organizando mejor los datos):

Código
  1.  
  2. typedef struct _nodo_ nodo;
  3. typedef struct _datos_ datos;
  4.  
  5. struct _datos_ {
  6.    long int valor1;
  7.    char* nombre;
  8.    long int valor2;
  9.    long int valor3;
  10. };
  11.  
  12. struct _nodo_ {
  13.   datos value;
  14.   nodo *siguiente;
  15.   nodo *anterior;
  16. };
  17.  
  18.  
316  Programación / Programación Visual Basic / Re: graficadora en visual basic en: 10 Agosto 2012, 09:12 am
Una iteracion es algo que se repite y esto lo realiza un for, while, etc... inclusive la recursividad.

Dulces Lunas!¡.
317  Programación / Programación Visual Basic / Re: [TUTORIAL] Comunicación Entre Ejecutables en: 10 Agosto 2012, 09:06 am
Si de hecho esta interesante eso de los ActiveX.

Dulces Lunas!¡.
318  Programación / Programación C/C++ / Re: pasar datos de una cola dinámica a otra cola... en: 10 Agosto 2012, 09:03 am
Mira se me ocurre que crees una FUNCIÓN que te extraiga dicho nodo de la lista (Ignoro tu estructura) ya sea solo el valor o la estructura plena, después crea otra función que solo ligue con otra.

Aun así te dejo este enlace de una lista doblemente enlazada.

http://c.conclase.net/edd/?cap=005

En la sección de descargas encuentras el código fuente, pero será mejor que te lees todo eso, en dado caso que no te quede claro o que prefieras textos en ingles tienes la pagina de la Universidad De Stanford (ignoro la liga por ahora).

Dulces Lunas!¡.
319  Programación / Programación C/C++ / Re: [DUDA] añadir espacios al utilizar la función strcat en: 10 Agosto 2012, 07:44 am
@Fire544
No es recomendable usar scanf() de esa manera...

Dulces Lunas!¡.
320  Programación / Programación C/C++ / Re: [DUDA] añadir espacios al utilizar la función strcat en: 9 Agosto 2012, 06:57 am
.
El realizar un strcat() en un buffer es para uno establecido dará POSIBLEMENTE un overflow de indices segun la lontitud de este... por ejemplo:

Código
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <windows.h>
  5.  
  6. int main(){
  7. char puerto[25], ip[25];
  8. char netcat[]="nc"; // produce un error por que aquí solo hay una dimension de 3 indices... y se requiere una aun mas grande...
  9.  
  10. printf("Introduce la IP:\t");
  11. scanf("%s",&ip);
  12. printf("Introduce el puerto:\t");
  13. scanf("%s",&puerto);
  14. strcat(netcat,ip);
  15. strcat(netcat,puerto);
  16.  
  17. system(netcat);
  18. while(getchar() !='\n');  
  19.  
  20. }
  21.  
  22.  

Estas haciendo la instrucción ya dicha pero dicha instrucción SOLO concatena mas NO redimensiona por lo tando debes tener un 3er buffer donde meter dicha concatenación CON UN BUFFER ADECUADO...

Código
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <windows.h>
  5.  
  6. int main()
  7. {
  8.    char *res = NULL;
  9.    const char COMANDO[] = "nc ";
  10.    char puerto[25] = {},
  11.         ip[25] = {},
  12.         buffer[sizeof COMANDO + sizeof puerto + sizeof ip - 2] = {}; // el menos 2 es por que dos de las variables tienen un caracter \0 el cual no nos interesan, por que no restar -3? es simple necesitamos un byte '\0'...
  13.  
  14. //    printf("%d\n", sizeof buffer); // oslo para saber cuanto buffer tenemos realmente...
  15.  
  16.    printf("Introduce la IP:\t"); fflush(stdout); // realizo un fflush debido a que en el printf() no termino con \n
  17.    fgets(ip, sizeof puerto - 1, stdin); // con este -1 nos aseguramos que el ultimo byte sea SIEMPRE un \0
  18.  
  19.    printf("Introduce el puerto:\t"); fflush(stdout); // realizo un fflush debido a que en el printf() no termino con \n
  20.    fgets(puerto, sizeof puerto - 1, stdin); // con este -1 nos aseguramos que el ultimo byte sea SIEMPRE un \0
  21.  
  22.    strcat(buffer, COMANDO);
  23.    strcat(buffer, ip);
  24.    strcat(buffer, puerto);
  25.  
  26.    //  sustituimos todos los '\n' por ' '
  27.    res = strpbrk(buffer, "\n");
  28.    while (res) {
  29.        *res = ' ';
  30.        res = strpbrk(res, "\n");
  31.    }
  32.  
  33. //    puts(buffer); // solo para mostrar el comando...
  34.  
  35.    system(buffer);
  36.  
  37.    fflush(stdin); // para que la siguiente instruccion no tenga problemas con el buffer de entrada la vació...
  38.    while(getchar() !='\n');
  39.  
  40.    return 0;
  41. }
  42.  
  43.  

Para mas información: http://www.cplusplus.com/reference/clibrary/cstring/strcat/

Yo me voy a jugar nos vemos.

Dulces Lunas!¡.
Páginas: 1 ... 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 43 44 45 46 47 ... 331
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines