指针在for循环中 [英] pointer in for loop

查看:359
本文介绍了指针在for循环中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我遇到了问题。


当我将字符串分配给
指针。


代码:


ptr-> main = malloc(sizeof(detail)*(660 )+1);

strcpy(ptr-> main [count] .key,token [i]);

printf(" key key%d%s ",count,ptr-> main [count] .key);但是当我尝试这样做时......

hello friends,
I am having a problem.

This code works just fine when I print as soon as I assign the string to
the pointer.

Code:

ptr->main = malloc(sizeof(detail)*(660)+1);
strcpy(ptr->main[count].key,token[i]);
printf("key key %d %s ",count, ptr->main[count].key);But when I try to do this....

展开 | 选择 | Wrap | 行号

推荐答案

问题转移到C / C ++论坛。
Question moved to C / C++ Forum.


它以什么方式不起作用?如果它给你编译错误,请在这里发布。如果它给你错误的输出,请在这里发布,以及预期的输出。这将使人们更容易帮助您。谢谢。
In what way does it not work? If it gives you compiler errors, please post them here. If it gives you the wrong output, please post it here, along with the expected output. This will make it much easier for people to help you. Thanks.


基本上这不打印任何东西
Basically this doesnt print anything
展开 | 选择 | Wrap | 行号


这篇关于指针在for循环中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆