C语言中如何直接访问一个指定地址?
可以啊,你把这个数值给一个指针,然后dereference这个指针就可以了。
很危险的,不要随便这样操作,因为你可能会修改重要的系统或者其他进程地址空间里的数据。
c语言获取url
txt读入温度,湿度等数据。
用printf()输出 HTML 文件。
#define LF 10
#define CR 13
int wendu,shidu;
char shijian[20];
FILE *fin;
// 打开data.txt,读入 wendu,shidu,shijian,关文件
// 下来输出
printf(“HTML%c”,LF);
printf(“HEADTITLEweb界面/TITLE/HEAD%c”,LF);
printf(“meta http-equiv=\”Content-Type\”
content=\”text/html\”; charset=\”gb2312\” /);
printf(“BODY%c”,LF);
printf(“H2温度:%d 湿度:%d 时间:%s/H2%c”,LF,wendu,shidu,shijian);
printf(“HR/BODY/HTML%c”,LF);
===============================================
网上留言获取,变量名字与网页定义有关。
char *cl;
char manydata[10240];
void getword(char *word, char *line, char stop) {
int x = 0,y;
for(x=0;((line[x]) (line[x] != stop));x++)
word[x] = line[x];
word[x] = ‘\0’;
if(line[x]) ++x;
y=0;
while(line[y++] = line[x++]);
}
void unescape_url(char *url) {
register int x,y;
for(x=0,y=0;url[y];++x,++y) {
if((url[x] = url[y]) == ‘%’) {
url[x] = x2c(url[y+1]);
y+=2;
}
}
url[x] = ‘\0’;
}
void plustospace(char *str) {
register int x;
for(x=0;str[x];x++) if(str[x] == ‘+’) str[x] = ‘ ‘;
}
返回信息长度:
char_l = atoi(getenv(“CONTENT_LENGTH”));
cl = manydata[0];
分离变量名与值(即内容):
for (i=0; i char_l ;i++) {
*( cl + i) = (char)fgetc(stdin) ;
};
*( cl + char_l) = ‘\0’;
查找需要的变量名与值:
for(x=0;cl[0] != ‘\0’; x++) {
m=x;
getword(w,cl,’=’);
plustospace(w);
unescape_url(w);
if( strcmp(w,”name”) == 0) {
getword(w,cl,”);
plustospace(w);
unescape_url(w);
strcpy(name,w);
}
。。。。
}
———————————
另外,团IDC网上有许多产品团购,便宜有口碑
c语言编程,输入url,输出为远程服务器地址部分
#includestdlib.h
#includestdio.h
int main(void){
char address[50];
char command[50];
,,请输入网址
sprintf(command,”nslookup %s “,address);
system (command);
getchar();
return 0;
}
手机敲的
c语言对url解码,该如何实现
CGI是比较古老的通用网关接口程序了,想打印数据很简单,只需要通过访问环境变量中post过来的变量名即可,如果是get则直接从URL解析出需要的变量即可。