Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

問一個問題

0 views
Skip to first unread message

小毛

unread,
Jul 2, 2004, 4:37:50 AM7/2/04
to
下面是我的程式
請問大大
為什麼我的H,會出現........

HH?? <==== ??是ASCII碼,貼出來變問號 應該出現4個H吧~~
是什麼原因呢
==========================================

#include<stdio.h>
#include<alloc.h>
#include<stdlib.h>
#include<conio.h>
#define N 1024

main()
{
clrscr();
char *p;
int i;

p=(char *)malloc(N);
if(p==NULL)
{
printf("malloc() error");
exit(1);
}
for(i=0;i<N;i++)
{
p[i]='H';
}
for (i=0;i<4;i++)
{
printf("%c",*(p+i));
free(p);
}
getch();
return 0;
}
--
※ Origin: 楓橋驛站<bbs.cs.nthu.edu.tw> ◆ From: 203-71-129-181.reserve.ksut.edu.tw

0 new messages