CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Jan 2017
    Posts
    17

    [RESOLVED] Returning and receiving an unsigned char array

    Why is this giving me a problem? How can I fix it? I'm basically passing a size containing a value of 2 to the makeArray function. Then I make an unsigned char* array Inside the makeArray function, fill its first two subscript, then return that array to main.cc.

    Error:
    main.cc:13:8: error: array type 'unsigned char *[size]' is not assignable

    array = makeArray(size);

    ~~~~~ ^

    1 error generated.

    make: *** [main.o] Error 1


    main.cc
    Code:
    	int size = 2;
    
    	unsigned char* array[size];
    
    	array = makeArray(size);
    
    
    	for (int i = 0; i < size; i++) {
    		printf("%s\n", array[i]);
    
    	} // end of for loop
    functions.cc
    Code:
    unsigned char* makeArray(int size) {
        unsigned char* array = new unsigned char[size];
    
        // fill in the array
        array[0] = '1';
        array[1] = '0';
    
        // return array
        return array;
    
    } // end of makeArray
    Last edited by asilvester635; February 16th, 2017 at 03:44 PM.

Tags for this Thread

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

Featured