|
-
Nov 11th, 2001, 12:56 AM
#1
Thread Starter
Hyperactive Member
Cast Requirement???
Hello,
I am new to Visual C++ and i am not sure what does " Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast" compiler error mean.
When ever i try to do something like
printf(arr[1]); or strcpy(dest,arr[1]); i get this error?
PHP Code:
#include "stdafx.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
char szc[5]="10;0";
char pzod[1];
void doarray(char arr[], int size)
{
char hj[1];
for(int i = 0; i < size; i++)
{
hj[1] = arr[i];
//Error caused here
strcpy(pzod,arr[i]);
//End Error
cout << hj[1];
}
}
int main(int argc, char* argv[])
{
int x;
doarray(szc,10);
cin >> x;
return 0;
}
I dont understand how to copy a character somewhere. All i need my prog to do is copy beginning of an array (2 chars) into a charactar string and end of an array (1 char) into a character array. Please help me to get rid of this cast errror.
Thanks for any help,
Thanks for your help,
-
Nov 11th, 2001, 06:41 AM
#2
strcpy is used to copy strings, not single chars. To copy single chars, simply use =
arr[1] is a single char because arr is an array of chars.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 11th, 2001, 04:00 PM
#3
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|