织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

How to皇冠 fix argument of type is incompatible with

时间:2025-11-06 03:07来源: 作者:admin 点击: 0 次
This is because your expression newItemIDPointer + i is a pointer to the character at offset i in the string, not the value (character) at that locati

This is because your expression newItemIDPointer + i is a pointer to the character at offset i in the string, not the value (character) at that location. You need to dereference the pointer to get the value, eg:

*(newItemIDPointer + i)

Or a more obvious way to do it is:

newItemIDPointer[i]

To explain: Let's say you have a pointer to a string, called p:

char *p = "ABCDE";

Let's say that the pointer p happens to have a value 0x4001. That would be the address of the first character in your string, which happens to be the letter ASCII value of A (I just totally made that number up, in practice the operating system and/or compiler determine the actual memory location)...

So then, p + 1 will give us 0x4002.. the location of the letter B. It is NOT the ASCII value of B, which happens to be 66 in decimal... That is what you want to be passed to isspace.. the value stored in that memory location, not the address of the memory location.

This is one of the toughest things for beginners to C, once you get a good visual in your head of when you are manipulating the address of a location in memory and when you are manipulating the data stored at that location, the rest of C is pretty easy...

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-11-06 15:11 最后登录:2025-11-06 15:11
栏目列表
推荐内容