Oct 1, 2011 at 5:13pm Oct 1, 2011 at 5:13pm UTC
I tried to make a simple c++ console program that encodes an ascii text to base64 text and then decode base64 text to ascii, but is shows nothig... can you please help me?
#include <iostream>
#include <string.h>
#include <fstream>
#include <math.h>
using namespace std;
int dec_to_bin(int value){
int c,r,r2,n;
c=value/2;
r2=value%2;
n=r2;
while(value!=0){
c=value/2;
r=value%2;
n=n*10+r;
}
return n;
}
void init_istring(char cstring[],int istring[],int n){
int subint[8],j,k,value,decvalue;
for(int i=0;i<n;i++){
decvalue=int(cstring[i]);
value=dec_to_bin(decvalue);
for(j=7;j>=0;j--){
subint[j]=value%10;
}
for(k=0;k<8;k++){
if(p>=8){
subint[k]=istring[k+(p-k)/8];
p++;
}
else{
subint[k]=istring[k];
p++;
}
}
}
}
void convert_istring(int istring[],int n){
int i,d=0,j=0,value=0;
for(d=0;d<n;d++){
for(i=d*6+5;i>=d*6;i--){
value=value*powl(10,j)+istring[i];
j++;
}
cout<<value<<" ";
value=0;
}
}
void main(){
char string[]="wgrt";
int s[32];
int n=4,x=3;
init_istring(string,s,n);
convert_istring(s,x);
cin>>n;
}
Oct 1, 2011 at 5:30pm Oct 1, 2011 at 5:30pm UTC
I tested this code in visual studio and I got this error:
LNK1561: entry point must be defined
Oct 1, 2011 at 5:37pm Oct 1, 2011 at 5:37pm UTC
Create a new console application with default settings, then add base64.h and base64.cpp to your project.
Add #include "base64.h"
to stdafx.h and edit main() to use base64_encode() or base64_decode() for testing.