char* a="HELLO WORLD";
Run Code Online (Sandbox Code Playgroud)
如果"H"的地址为0x01,那么带有%s的printf将打印到D但是如果使用手动打印程序写入相同的代码
while(*a!=NULL) {printf("%c",n[a]);n++;}
Run Code Online (Sandbox Code Playgroud)
这会打印出更多的字符..但是
printf("%s",a);
完美打印.
while(*a++) printf("%c", *(a-1)); or
for(;*a++;)printf("%c", *(a-1));
Run Code Online (Sandbox Code Playgroud)
虽然工作,但我不想要解决方案,但过程机制..
所以我想到的问题是
printf是从某个寄存器(或任何内存单元)获取字符串的长度还是执行字符检查..然后打印...
这个程序在第一次参数后挂起: -
#include <stdio.h>
#include <conio.h>
void ellip(char*,...);
int main(int argc,char* argv[]){
printf("a");
ellip("first argument",99,"second arg","thirdarg");
_getch();
return 0;
}
void ellip(char* m,...)
{ char com='c';
for(;;)
{
auto g=0;
while(com=='c')
{
printf("%d\nMatched Continue:-",g++);
scanf("%c",&com);
}
}
}
Run Code Online (Sandbox Code Playgroud)
而同一程序有一个微妙的修改(增加空间)
scanf("%c ",&com);
Run Code Online (Sandbox Code Playgroud)
工作良好!
这是vc中的某种错误还是计算机中的问题?