Results 1 to 3 of 3

Thread: Cast Requirement???

  1. #1

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394

    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 0sizei++)
        {
            
    hj[1] = arr[i];
    //Error caused here
    strcpy(pzod,arr[i]);
    //End Error
            
    cout << hj[1];
        }
    }


    int main(int argccharargv[])
    {
    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,
    VS.NET 2003

    Need to email me?

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    Hyperactive Member made_of_asp's Avatar
    Join Date
    Jul 2001
    Location
    123 Fake Street
    Posts
    394
    Thanks
    VS.NET 2003

    Need to email me?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width