69,382
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<string.h>
int main()
{
char ch[20];
int i, len;
printf("enter a row:");
for(i = 0; (ch[i]=getchar()) !='\n'; i++)
;
ch[i] = 0; /* add '\0' */
printf("reshow:");
len = strlen(ch);
printf("%d\n", len);
for(i = 1; i <= len; i++) {
printf("%c", ch[len-i]);
}
printf("\n");
return 0;
}
一般遇到输出字符串时出现乱码,基本上都是没有加上字符串结束标记;建议下次遇到类似问题先检查字符串结束标识是否存在。windows里常见的内存填充数据含义
* 0xABABABAB : Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after allocated heap memory
漱 * 0xABADCAFE : A startup to this value to initialize all free memory to catch errant pointers
涵? * 0xBAADF00D : Used by Microsoft's LocalAlloc(LMEM_FIXED) to mark uninitialised allocated heap memory
很? * 0xBADCAB1E : Error Code returned to the Microsoft eVC debugger when connection is severed to the debugger
撅饰 * 0xBEEFCACE : Used by Microsoft .NET as a magic number in resource files
烫烫 * 0xCCCCCCCC : Used by Microsoft's C++ debugging runtime library to mark uninitialised stack memory
屯屯 * 0xCDCDCDCD : Used by Microsoft's C++ debugging runtime library to mark uninitialised heap memory
葺葺 * 0xDDDDDDDD : Used by Microsoft's free() or delete to mark freed heap memory
蕲蕲 * 0xDEADDEAD : A Microsoft Windows STOP Error code used when the user manually initiates the crash
* 0xFDFDFDFD : Used by Microsoft's C++ debugging heap to mark "no man's land" guard bytes before and after allocated heap memory
* 0xFEEEFEEE : Used by Microsoft's HeapFree() to mark freed heap memory