程序有警告
#include <stdio.h>
char strtobit(char str[]) {
char result=0,i=0;
for(i=0;str[i]!='\0';++i) {
result = (result<<1) + str[i] - '0';
}
return result;
}
int main() {
char source[]="ddssssasdfasdfasdfaqwfasdfawefasdfasdfawedasdfaw";
int i=1,j=0;
char tmp1[9];
for(i=1;source[i]!='\0';++i) {
tmp1[j]=source[i];
j++;
if(i%8==0) {
tmp1[j] = '\0';
printf('%s', tmp1);
printf('%c', strtobit(tmp1));
j=0;
}
}
getch();
}
#include <stdio.h>
#include <conio.h>
char strtobit(char str[]) {
char result=0,i=0;
for(i=0;str[i]!='\0';++i)
{
result = (result<<1) + str[i] - '0';
}
return result;
}
int main() {
char source[]="ddssssasdfasdfasdfaqwfasdfawefasdfasdfawedasdfaw";
int i=1,j=0;
char tmp1[9];
for(i=1;source[i]!='\0';++i)
{
tmp1[j]=source[i];
j++;
if(i%8==0)
{
tmp1[j] = '\0';
printf("%s\n",tmp1);//应该是双引号
printf("%c\n", strtobit(tmp1));//应该是双引号
j=0;
}
}
getch();//头文件应该包含#include <conio.h>
}