Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22070

Convert from int array to char array

$
0
0

After searching around I couldn't understand how to convert a value obtained from an int array [x] to char array [x]Executing this code gives me a null result.

I saw syntax like char x = 98;

Its work with single var but doesnt work with array.

#include  <stdio.h>int main(void){    int st[6]={99,102,107,111,117,121};    int cl = 0;    char pw[7]={'\0'};    for (cl = 0; cl > 7; cl++){        if (cl == 1){ pw[1] =  st[2];}        if (cl == 2){ pw[2] =  st[5];}        if (cl == 3){ pw[3] =  st[1];}        if (cl == 4){ pw[4] =  st[3];}        if (cl == 5){ pw[5] =  st[6];}        if (cl == 6){ pw[6] =  st[4];}        if (cl == 7){ pw[7] =  st[5];}    }                    printf("\n : %c ", pw);                    return 0;}

I need the code to encrypt text and then decipher them.I'd like to know where I'm wrong.PS: If you run the code I don't take responsibility for the result.


Viewing all articles
Browse latest Browse all 22070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>