Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- char start_1[]="za"; //
- char choice_aa[]="aa"; //
- char choice_bb[]="bb"; //
- char choice_ab[]="ab"; //
- char choice_ba[]="ba"; //
- char start_2[]="za"; //
- char *user_imput; //
- char stop_1[]="az";
- char stop_2[]="bz";
- char binary[20]; //
- int exit_while = 1;
- int arr_position = 0;
- int allocate(char *stringHelper, char *user_imput, int cont) {
- stringHelper[0] = *(user_imput+cont);
- cont++;
- stringHelper[1] = *(user_imput+cont);
- cont++;
- return cont;
- }
- int _allocate(char *strHelper, char* user_imput, int cont)
- {
- }
- int main(){
- user_imput = (char*)malloc(sizeof(char) * 1024);
- printf("Inserisci il tuo segnale digitale :\n");
- scanf("%s",user_imput);
- int cont = 0;
- char stringHelper[3]; //3 perchè c'è anche il terminatore, dubito tu lo userai ma nel dubbio non corriamo il rischio
- cont=allocate(&stringHelper, user_imput, cont);
- if(strcmp(start_1, stringHelper)==0 || strcmp(start_2, stringHelper)==0) {
- printf("Inizio la conversione");
- } else {
- exit_while += 2; //Così non entra nel while
- }
- while(exit_while <= 2) {
- cont=allocate(&stringHelper, user_imput, cont); //Scorre l'user_imput e alloca i caratteri a due a due nella stringa d'appoggio
- if(strcmp(stringHelper, choice_aa) == 0 || strcmp(stringHelper, choice_bb) == 0) {
- printf("1\n");
- }
- if(strcmp(stringHelper, choice_ab) == 0 || strcmp(stringHelper, choice_ba) == 0) {
- printf("0\n");
- }
- if(strcmp(stringHelper, stop_1) == 0 || strcmp(stringHelper, stop_2) == 0) {
- return -1;
- exit_while = exit_while + 2;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement