C 地址到字符串常数

C 地址到字符串常数,c,C,我从汇编程序中得到一个字符串的地址到C,我需要得到这个地址的内容。 怎么做?谷歌给出C++实例,其中使用RealTytCube,但它不能在C(i)中工作。 如果您也注意到所需的LIB,我将不胜感激,tenx #include <stdio.h> #include <stdlib.h> unsigned long const1(void); int main() { printf("Const: %d\n", const1()); return

我从汇编程序中得到一个字符串的地址到C,我需要得到这个地址的内容。 怎么做?谷歌给出C++实例,其中使用RealTytCube,但它不能在C(i)中工作。 如果您也注意到所需的LIB,我将不胜感激,tenx

#include <stdio.h> 
#include <stdlib.h> 

unsigned long const1(void); 

int main()
{ 
    printf("Const: %d\n", const1()); 
    return 0; 
}
#包括
#包括
无符号长常量1(无效);
int main()
{ 
printf(“常数:%d\n”,常数1());
返回0;
}
如果您知道字符串后面有一个带零的字节,请尝试以下操作:

char* p = (char*) <your address here>;
// use p for whatever here
char*p=(char*);
//这里用p表示任何东西
如果字符串后面没有零,则C中的标准字符串函数将失败。

如果您知道字符串后面有一个带零的字节,请尝试以下操作:

char* p = (char*) <your address here>;
// use p for whatever here
char*p=(char*);
//这里用p表示任何东西

如果字符串后面没有零,那么C中的标准字符串函数将失败。

如果您已经获得了地址,并且知道它是以null结尾的字符串,那么您需要做的就是将其视为字符串

printf("%s", (char*)alleged_string_address);

如果您已经获得了地址,并且知道它是以null结尾的字符串,那么您所需要做的就是将其视为字符串

printf("%s", (char*)alleged_string_address);

在我等待您的信息时,初步回答:

   char* foo = (char*)...pointer from assembly...;
    *foo = 'a'; /* write a to the address pointed at by foo */
    foo++;      /* increment the address of foo by 1 */
    *foo = 'b'; /* write b to that address.  foo now contains ab, if it points at RAM.  */
这个答案是面向嵌入式系统的。如果需要指向外围寄存器之类的指针,请使用volatile来避免编译器优化

   volatile char* foo = (char*)...pointer from assembly...;
    *foo = 'a'; /* write a to the address pointed at by foo */
    foo++;      /* increment the address of foo by 1 */
    *foo = 'b'; /* write b to that address.  foo now contains ab, if it points at RAM.  */

在我等待您的信息时,初步回答:

   char* foo = (char*)...pointer from assembly...;
    *foo = 'a'; /* write a to the address pointed at by foo */
    foo++;      /* increment the address of foo by 1 */
    *foo = 'b'; /* write b to that address.  foo now contains ab, if it points at RAM.  */
这个答案是面向嵌入式系统的。如果需要指向外围寄存器之类的指针,请使用volatile来避免编译器优化

   volatile char* foo = (char*)...pointer from assembly...;
    *foo = 'a'; /* write a to the address pointed at by foo */
    foo++;      /* increment the address of foo by 1 */
    *foo = 'b'; /* write b to that address.  foo now contains ab, if it points at RAM.  */

向我们展示您尝试过的代码以及它不起作用的地方。什么编译器?什么架构?
#include#include无符号长常量1(void);int main(){printf(“Const:%d\n”,const1());返回0;}
const1()返回stringarchitecture的地址:ARM XScale向我们展示您尝试过的代码以及它不起作用的地方。什么编译器?什么架构?
#include#include无符号长常量1(void);int main(){printf(“Const:%d\n”,const1());返回0;}
const1()返回stringarchitecture的地址:ARM Xscale+1 for
volatile
,它是专门为这样的东西制作的。+1 for
volatile
,它是专门为这样的东西制作的。