'别加错位置。。。如果英文字符都不可以正确显示的"og:type" content="webpage">'别加错位置。。。如果英文字符都不可以正确显示的" /> '别加错位置。。。如果英文字符都不可以正确显示的"> C语言C++,用recv获取网页源代码,中文为什么是乱码 代码如下:_服务器_内存溢出

阅读 49

C语言C++,用recv获取网页源代码,中文为什么是乱码 代码如下:,第1张

这种问题通常是你的代码

在处理字符串是弄错了。。。
接收过来的内容应该没问题吧。。。。
只是显示的时候弄错了吧。。仔细检查一下,中文字符占2个字节,指针头别弄错了,最后加上'\0'别加错位置。。。如果英文字符都不可以正确显示的话

,那可能是粘包。
还有是不是编码问题。
#include <stdioh>
int main()
{
    printf("这样的源代码是可以的。");

    return 0;
}c cpp h 这三类是源文件,直接用notepad就可以了至于exe的话,只好用反编译

软件了
对任何的反编译软件来说,100%原样反编译是没有可能的,对汇编做反编译也是如此!但是反编译出来的代码是完全可以执行的!
>#include <stdioh>
#include <stdlibh>
#include <stringh>
#include <conioh>
#include <ctypeh>
#define ESC 27
#define NULL0
#define LEN sizeof(struct applicant)
#define LENB sizeof(struct job)
#define L sizeof(info1)
#define LB sizeof(info2)
int n,k;
char filename1[10];
char filename2[10];
struct applicant
{
long anum;
char aname[10];
char id[18];
char cert[20];
char rqurjob[20];
struct applicant next1;
}applcnt[60],info1;
struct job
{
long jnum;
char jname[20];
int need;
struct job next2;
}jb[100],info2;
/------------color--------------/
color()
{
int x1=20,y1=5,x2=60,y2=40,i;
clrscr();
textmode(3);
textbackground(2);
window(x1,y1,x2,y2);
for(i=1;i <=21;i++)
{
gotoxy(1,i);cprintf( " ");}
}
/-------------menu-----------/
menu()
{
char c;
color(); textcolor(19); gotoxy(17,3);cprintf( "MENU "); textcolor(4);
gotoxy(9,5);cprintf( "1 --input applicant record ");
gotoxy(9,6);cprintf( "2 --output applicant record ");
gotoxy(9,7);cprintf( "3 --delete applicant record ");
gotoxy(9,8);cprintf( "4 --insert applicant record ");
gotoxy(9,9);cprintf( "5 --search applicant record ");
gotoxy(9,10);cprintf( "6 --open applicant record ");
gotoxy(9,11);cprintf( "7 --input job record ");
gotoxy(9,12);cprintf( "8 --output job record ");
gotoxy(9,13);cprintf( "9 --delete job record ");
gotoxy(9,14);cprintf( "10 --search jobe record ");
gotoxy(9,17);cprintf( "0 --exit ");
gotoxy(15,20);cprintf( "Please Select: ");
c=getch();
if(ESC==c)exit(0);
return(c);
}
/---------------create applicant information---------------/
struct applicant create1(void)
{
struct applicant p1, p2; struct applicant head1;
struct applicant load1(void);
struct applicant arrange1(struct applicant head1);
char c;
color();
n=0;
p1=p2=(struct applicant )malloc(LEN);
textcolor(14);
gotoxy(7,3);cprintf( "Please Enter Record: ");
textcolor(1);
gotoxy(5,5);cprintf( "Enter Num: "); scanf( "%1d ",&p1-> anum);
if(p1-> anum==0){head1=NULL;goto end;}
gotoxy(5,7);cprintf( "Enter Name: "); scanf( "%s ",p1-> aname);
gotoxy(5,9);cprintf( "Enter Your ID Number: "); scanf( "%s ",p1-> id);
gotoxy(5,11);cprintf( "Enter Your Certification: "); scanf( "%s ",p1-> cert);
gotoxy(5,13);cprintf( "Enter Your Ideal Job: "); scanf( "%s ",p1-> rqurjob);
head1=NULL;
while(p1-> anum!=0)
{
n=n+1;
if(n==1)head1=p1;
else p2-> next1=p1;
p2=p1;
p1=(struct applicant )malloc(LEN);
color();
textcolor(14);
gotoxy(6,3);cprintf( "Please Enter Record: ");
textcolor(1);
gotoxy(5,5);cprintf( "Enter Num: "); scanf( "%1d ",&p1-> anum);
if(p1-> anum==0) goto end;
gotoxy(5,7);cprintf( "Enter Name: "); scanf( "%s ",p1-> aname);
gotoxy(5,9);cprintf( "Enter Your ID number: "); scanf( "%s ",p1-> id);
gotoxy(5,11);cprintf( "Enter Your Certification: "); scanf( "%s ",p1-> cert);
gotoxy(5,13);cprintf( "Enter Your Ideal Job: "); scanf( "%s ",p1-> rqurjob);
}
end:p2-> next1=NULL;
head1=arrange1(head1);
gotoxy(5,16);cprintf( "Save(Yor,N) ");
c=getch();
if(c== 'Y '||c== 'y ')save1(head1);
else head1=load1();
return(head1);
}
/---------------------create job information----------------------/
struct job create2(void)
{
struct job p3, p4; struct job head2;
struct job load2(void);
struct job arrange2(struct job head2);
char d;
color();
k=0;
p3=p4=(struct job )malloc(LENB);
textcolor(14);
gotoxy(7,3);cprintf( "Please Enter Record: ");
textcolor(1);
gotoxy(5,5);cprintf( "Enter Job Number: "); scanf( "%1d ",&p3-> jnum);
if(p3-> jnum==0){head2=NULL;goto end;}
gotoxy(5,7);cprintf( "Enter Job Name: "); scanf( "%s ",p3-> jname);
gotoxy(5,9);cprintf( "Enter The Amount Of The Job Needs: "); scanf( "%i ",p3-> need);
head2=NULL;
while(p3-> jnum!=0)
{
k=k+1;
if(k==1)head2=p3;
else p4-> next2=p3;
p4=p3;
p3=(struct job )malloc(LENB);
color();
textcolor(14);
gotoxy(7,3);cprintf( "Please Enter Record: ");
textcolor(1);
gotoxy(5,5);cprintf( "Enter Job Number: "); scanf( "%1d ",&p3-> jnum);
if(p3-> jnum==0) goto end;
gotoxy(5,7);cprintf( "Enter Job Name: "); scanf( "%s ",p3-> jname);
gotoxy(5,9);cprintf( "Enter The Amount Of The Job Needs: "); scanf( "%i ",p3-> need);
}
end:p4-> next2=NULL;
head2=arrange2(head2);
gotoxy(5,12);cprintf( "Save(YOr,N) ");
d=getch();
if(d== 'Y '||d== 'y ')save2(head2);
else head2=load2();
return(head2);
}
/--------------print applicant information----------------/
void print1(struct applicant head1)
{
struct applicant p5;int i=0;
color();textcolor(14);
p5=head1; textcolor(4);
if(head1-> anum==0)
{ gotoxy(4,4);cprintf( "NO info of applicant! "); }
else
{
gotoxy(2,2);cprintf( "Number of Records:%d ",n);
textcolor(0);
gotoxy(5,4);cprintf( "Num Name ID Certification Required job ");
if(head1!=NULL)textcolor(1);
do{
gotoxy(5,5+i);cprintf( "%1d ",p5-> anum);
gotoxy(18,5+i);cprintf( "%s ",p5-> aname);
gotoxy(32,5+i);cprintf( "%s ",p5-> id);
gotoxy(50,5+i);cprintf( "%s ",p5-> cert);
gotoxy(75,5+i);cprintf( "%s ",p5-> rqurjob);
i++;
p5=p5-> next1;
}while(p5!=NULL);
}
textcolor(14);
gotoxy(15,20);cprintf( "Any Key Back! ");
getch();
}
/--------------print job information----------------/
void print2(struct job head2)
{
struct job p7;int k=0;
color();textcolor(14);
p7=head2; textcolor(4);
if(head2-> jnum==0)
{ gotoxy(4,4);cprintf( "NO info of student! "); }
else
{
gotoxy(2,2);cprintf( "Number of Records:%d ",k);
textcolor(0);
gotoxy(5,4);cprintf( "Job Number Job name Amount of Person in need ");
if(head2!=NULL)textcolor(1);
do{
gotoxy(5,5+k);cprintf( "%1d ",p7-> jnum);
gotoxy(18,5+k);cprintf( "%s ",p7-> jname);
gotoxy(43,5+k);cprintf( "%i ",p7-> need);
k++;
p7=p7-> next2;
}while(p7!=NULL);
}
textcolor(14);
gotoxy(15,20);cprintf( "Any Key Back! ");
getch();
}
/----------delelte applicant-----------/
struct applicant del1(struct applicant head1)
{
struct applicant p1, p2;long anum;char c;
color();textcolor(14);
gotoxy(7,3);cprintf( "Eneter Delete Applicant Number: ");
scanf( "%1d ",&anum);
textcolor(128+4);
if(head1==NULL) {gotoxy(12,7);printf( "List Null!) ");goto end; }
p1=head1;
while(anum!=p1-> anum&&p1-> next1!=NULL)
{ p2=p1;p1=p1-> next1;}
if(anum==p1-> anum)
{
if(p1==head1)head1=p1-> next1;
else p2-> next1=p1-> next1;
gotoxy(11,7);
cprintf( "%1d Has Been Deleted! ",anum);
n=n-1;
textcolor(14);
gotoxy(5,12);cprintf( "Save(YorN) ");
c=getch();
if(c== 'Y '|| c== 'y ')save1(head1);
}
else
{
textcolor(128+4);gotoxy(11,7);
cprintf( "%1d Not Been Found! ",anum);
end:textcolor(14);
gotoxy(15,14);cprintf( "Any Key Back! ");getch();
}
}
/---------------delete job-----------/
struct job del2(struct job head2)
{
struct job p3, p4;long jnum;char d;
color();textcolor(14);
gotoxy(7,3);cprintf( "Eneter Delete job Number: ");
scanf( "%1d ",&jnum);
textcolor(128+4);
if(head2==NULL) {gotoxy(12,7);printf( "List Null!) ");goto end; }
p3=head2;
while(jnum!=p3-> jnum&&p3-> next2!=NULL)
{ p4=p3;p3=p3-> next2;}
if(jnum==p3-> jnum)
{
if(p3==head2)head2=p3-> next2;
else p4-> next2=p3-> next2;
gotoxy(11,7);
cprintf( "%1d Has Been Deleted! ",jnum);
k=k-1;
textcolor(14);
gotoxy(5,12);cprintf( "Save(YorN) ");
d=getch();
if(d== 'Y '|| d== 'y ')save2(head2);
}
else
{
textcolor(128+4);gotoxy(11,7);
cprintf( "%1d Not Been Found! ",jnum);
end:textcolor(14);
gotoxy(15,14);cprintf( "Any Key Back! ");getch();
}
}
/---------------------arrange applicant--------/
struct applicant arrange1(struct applicant head1)
{
int i,j;struct applicant p5;
p5=head1;
for(i=0;i <n;i++) {applcnt[i]= p5;p5=p5-> next1;}
for(j=1;j <n-1;j++)
{
for(i=1;i <=n-j;i++)
if(applcnt[i-1]anum> applcnt[i]anum)
{info1=applcnt[i-1];applcnt[i-1]=applcnt[i];applcnt[i]=info1; }
}
p5=&applcnt[0];
for(i=1;i <n;i++)
{ p5-> next1=&applcnt[i];p5=p5-> next1;}
p5-> next1=NULL;head1=&applcnt[0];
return(head1);
}
/-----------------arrange job-------------------/
struct job arrange2(struct job head2)
{
int r,f;struct job p7;
p7=head2;
for(r=0;r <k;r++) {jb[r]= p7;p7=p7-> next2;}
for(f=1;f <k-1;f++)
{
for(r=1;r <=k-f;r++)
if(jb[r-1]jnum> jb[r]jnum)
{info2=jb[r-1];jb[r-1]=jb[r];jb[r]=info2; }
}
p7=&jb[0];
for(r=1;r <k;r++)
{ p7-> next2=&jb[r];p7=p7-> next2;}
p7-> next2=NULL;head2=&jb[0];
return(head2);
}
/--------------------insert applicant-----------------/
struct applicant insert1(struct applicant head1)
{
struct applicant p0, p1, p2, applcnt;char c;
color();
applcnt=(struct applicant )malloc(LEN);
textcolor(14);
gotoxy(7,3);cprintf( "Please Enter Record: ");
textcolor(1);
gotoxy(5,5);cprintf( "Enter Num: "); scanf( "%1d ",&applcnt-> anum);
gotoxy(5,7);cprintf( "Enter Name: "); scanf( "%s ",applcnt-> aname);
gotoxy(5,9);cprintf( "Enter Your ID Number: "); scanf( "%s ",applcnt-> id);
gotoxy(5,11);cprintf( "Enter Your Certification: "); scanf( "%s ",applcnt-> cert);
gotoxy(5,13);cprintf( "Enter Your Ideal Job: "); scanf( "%s ",applcnt-> rqurjob);
p1=head1; p0=applcnt;
if(head1=NULL)
{ head1=p0;p0-> next1=NULL;}
else
while((p0-> anum> p1-> anum)&&(p1-> next1!=NULL))
{ p2=p1; p1=p1-> next1;}
if(p0-> anum <=p1-> anum)
{
if(head1==p1)head1=p0;
else p2-> next1=p0; p0-> next1=p1;
}
else {p1-> next1=p0;p0-> next1=NULL;}
n=n+1;
textcolor(14);
gotoxy(5,16);cprintf( "Save(Yor,N) ");
c=getch();
if(c== 'Y '||c== 'y ')save1(head1);
head1=load1();
return(head1);
}
/------------------insert job----------------------/
struct job insert2(struct job head2)
{
struct job q0, p3, p4, jb;char d;
color();
jb=(struct job )malloc(LENB);
textcolor(14);
gotoxy(7,3);cprintf( "Please Enter Job Num: ");
textcolor(1);
gotoxy(5,5);cprintf( "Enter Job Number: "); scanf( "%1d ",&jb-> jnum);
gotoxy(5,7);cprintf( "Enter Job Name: "); scanf( "%s ",jb-> jname);
gotoxy(5,9);cprintf( "Enter The Amount Of The Job Needs: "); scanf( "%i ",jb-> need);
p3=head2; q0=jb;
if(head2==NULL)
{ head2=q0;q0-> next2=NULL;}
else
while((q0-> jnum> p3-> jnum)&&(p3-> next2!=NULL))
{ p4=p3; p3=p3-> next2;}
if(q0-> jnum <=p3-> jnum)
{
if(head2==p3)head2=q0;
else p4-> next2=q0; q0-> next2=p3;
}
else { p3-> next2=q0;q0-> next2=NULL;}
k=k+1;
textcolor(14);
gotoxy(5,12);cprintf( "Save(Yor,N) ");
d=getch();
if(d== 'Y '||d== 'y ')save2(head2);
head2=load2();
return(head2);
}
/----------------------load applicant------------------------/
struct applicant load1(void)
{
struct applicant p1, p2, head1;
FILE fp;
color();textcolor(14);
gotoxy(3,5);cprintf( "Please Enter Loaded Applicant File Name: ");
scanf( "%s ",filename1);
fp=fopen( "filename1dat ", "r ");
fscanf(fp, "%s ",filename1);
fclose(fp);
if((fp=fopen(filename1, "rb "))==NULL)
{
textcolor(128+4);gotoxy(3,4);
cprintf( "Info1 been not found from %s ! ",filename1);
goto end;
}
p2=p1=(struct applicant )malloc(LEN);
n=0;
while(! feof(fp))
{
n=n+1;if(n==1)head1=p1;
fread(p1,LEN,1,fp);
p2=p1;
p1=(struct applicant )malloc(LEN);
p2-> next1=p1;
}
fclose(fp);
n=n-1;
p2-> next1=NULL;
for(p1=head1;p1-> next1-> next1!=NULL;p1=p1-> next1);
p1-> next1=NULL;
clrscr(); textcolor(128+4);
gotoxy(3,5);cprintf( "Info1 Has Been Loaded from %s! ",filename1);
end:textcolor(14);
gotoxy(15,14);cprintf( "Any Key Back! ");
getch();
return(head1);
}
/--------------load job-------------------/
struct job load2(void)
{
struct job p3, p4, head2;
FILE fp;
color();textcolor(14);
gotoxy(3,5);cprintf( "Please Enter Loaded Job File Name: ");
scanf( "%s ",filename2);
fp=fopen( "filename2dat ", "r ");
fscanf(fp, "%s ",filename2);
fclose(fp);
if((fp=fopen(filename2, "rb "))==NULL)
{
textcolor(128+4);gotoxy(3,4);
cprintf( "Info2 been not found from %s ! ",filename2);
goto end;
}
p4=p3=(struct job )malloc(LENB);
k=0;
while(! feof(fp))
{
k=k+1;if(k==1)head2=p3;
fread(p3,LENB,1,fp);
p4=p3;
p3=(struct job )malloc(LENB);
p4-> next2=p3;
}
fclose(fp);
k=k-1;
p4-> next2=NULL;
for(p3=head2;p3-> next2-> next2!=NULL;p3=p3-> next2);
p3-> next2=NULL;
clrscr(); textcolor(128+4);
gotoxy(3,5);cprintf( "Info2 Has Been Loaded From %s! ",filename2);
end:textcolor(14);
gotoxy(15,14);cprintf( "Any Key Back! ");
getch();
return(head2);
}
/---------------------save applicant------------------------/
save1(struct applicant head1)
{
FILE fp; struct applicant p5;
color();textcolor(14);
p5=head1;
gotoxy(3,5);cprintf( "Please Enter Saved Applicant File Name: ");
scanf( "%s ",filename1);
fp=fopen( "filename1dat ", "w ");
fprintf(fp, "%s ",filename1);
fclose(fp);
fp=fopen(filename1, "wb ");
while(p5=NULL){ fwrite(p5,LEN,1,fp);p5=p5-> next1;}
fclose(fp);
textcolor(128+4);clrscr();
gotoxy(2,3);
cprintf( "%d Applicant Record Has Been Saved To %s ! ",n,filename1);
textcolor(14);
gotoxy(15,14);cprintf( "Any Key Back! ");getch();
}
/------------------save job------------------------/
save2(struct job head2)
{
FILE fp; struct job p7;
color();textcolor(14);
p7=head2;
gotoxy(3,5);cprintf( "Pleas Enter Saved Job File Name: ");
scanf( "%s ",filename2);
fp=fopen( "filename2dat ", "w ");
fprintf(fp, "%s ",filename2);
fclose(fp);
fp=fopen(filename2, "wb ");
while(p7=NULL){ fwrite(p7,LENB,1,fp);p7=p7-> next2;}
fclose(fp);
textcolor(128+4);clrscr();
gotoxy(2,3);
cprintf( "%d Job Record Has Been Saved To %s ! ",k,filename2);
textcolor(14);
gotoxy(15,14);cprintf( "Any Key Back! ");getch();
}
/------------------------main-------------------------/
main()
{
char m,c;
struct applicant head1;
struct job head2;
textmode(7);textmode(3); textbackground(11);
color();textcolor(14);
gotoxy(12,5);cprintf( "Welcome To Use ");
textcolor(14);
gotoxy(7,7);cprintf( "Intermediary Information Management System ");
gotoxy(12,9);cprintf( "Written By Aaron Harvey ");
textcolor(128+11); gotoxy(2,14);
cprintf( " Any Key Continue! ESC to exit ");
c=getch();
if(ESC==c)exit(0);
menu:
m=menu();
switch(m)
{
case '1 ':head1=create1(); break;
case '2 ':print1(head1); break;
case '3 ':head1=del1(head1); break;
case '4 ':head1=insert1(head1); break;
case '5 ':head1=load1(); break;
case '6 ':head2=create2(); break;
case '7 ':print2(head2); break;
case '8 ':head2=del2(head2); break;
case '9 ':head2=insert2(head2); break;
case '10 ':head2=load2(); break;
case '0 ':textmode(11); exit(0);
}

goto menu;

}

#include<stdioh>

#include<stdlibh>

void main()

{

  inta,n,i,j,t;

  printf("input n:");

  scanf("%d",&n);

  a=(int)malloc(nsizeof(int));

  printf("input array:");

  for(i=0;i<n;i++)

      scanf("%d",a+i);

  for(i=1;i<n;i++)

      for(j=0;j<n-i;j++)

        if(a[j]>a[j+1])

          {t=a[j];

          a[j]=a[j+1];

          a[j+1]=t;

      }

     

      printf("差值为:%d\n",a[n-1]-a[0]);

}
你把我这个答案黏贴上去,绝对不会错!

欢迎分享,转载请注明来源:

内存溢出

原文地址:

http://outofmemory.cn/zz/13505823.html
中文
(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
招商银行保险 招商银行保险 一级用户组
nec的官方网站是什么?
上一篇
2023-08-20
Dream maill 错误代码501
2023-08-20

发表评论
请登录后评论... 登录
提交

    评论列表(0条)
保存
{label} {label}