unclear about typecasting and creating pointers

This is a discussion on unclear about typecasting and creating pointers within the C Programming forums, part of the General Programming Boards category; I am trying make a variable (check) that will change in a while loop that pulls a single character from ...

unclear about typecasting and creating pointers

I am trying make a variable (check) that will change in a while loop that pulls a single character from an array of strings (arra). It was giving me lots of errors about creating pointers without casts, I looked up typecasting but I'm not sure if I'm understanding it very well. I ended up with this code, but I am getting the error: "warning: cast to pointer from integer of different size" on the strcpy line. Any other combination of casts gives lines of errors. Any idea what I'm still doing wrong?

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

'check' is an integer, so you shouldn't be pretending it's a string.
'arra' is ... no one knows, because you didn't show us in your example. More than likely you are accessing a single character, and not a 'word'/'string'/'row' of it.

I tried creating the pointer straight out and it gave me a whole bunch of errors so I tried using strcpy. The while loops are after this part of code to go through the entire array called "arra" which i specified in my explanation. I am trying to assign "check" a single character from the array "arra". I changed "check" to an integer because the compile was giving me an error that I should be casting it as an character later. I'm very confused at this point.

My question is this: How do I reference a single character of an array of strings and assign it to the variable "check"?

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

The thing is, you showed even more code, yet the declaration of arra is still missing.

EDIT:
That said, one thing to note is that your character variable is incremented, but never reset. It looks like you do not even need temp. You are probably looking to use strtok() to tokenise the string based on ','.

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.

1. 'row' should start at 0, not at 1.
2. the 'for' loop only executes the first 'while', not all of the ones after it.
3. You 'character' plows off the end of all of your arrays.
4. Why do you have so many huge arrays?

The thing is, you showed even more code, yet the declaration of arra is still missing.

EDIT:
That said, one thing to note is that your character variable is incremented, but never reset. It looks like you do not even need temp. You are probably looking to use strtok() to tokenise the string based on ','.