One last question

I know i've been posting alot lately and you guys have been kind enough to put up with me but i have 1 more question....
I seem to be having trouble making a class function output a character array..... you see the class takes in a character array and then is supposed to spit out a character array im just6 not sure why but
it keeps saying...
return from char to char lacks a cast

or if i use INT to declare my sub it says

return from int to char lacks a cast

any help plz?
[Size=5][blue]J[/blue][/size][size=3][red]eripedo[/red][/size]
[code]If Userclue > 0 then
msgbox("Woohoo that Makes one")
end if[/code]
So... How long do you think you'll be waiting?

Comments

  • : I know i've been posting alot lately and you guys have been kind enough to put up with me but i have 1 more question....
    : I seem to be having trouble making a class function output a character array..... you see the class takes in a character array and then is supposed to spit out a character array im just6 not sure why but
    : it keeps saying...
    : return from char to char lacks a cast
    :
    : or if i use INT to declare my sub it says
    :
    : return from int to char lacks a cast


    You'll probably have to post some source code to get an answer.
  • DOH SORRY my bad here we are...

    [code]
    char formatting(char worker[59])
    {
    ssnum[0] = worker[0];
    ssnum[1] = worker[1];
    ssnum[2] = worker[2];
    ssnum[3] = worker[3];/**/
    ssnum[4] = worker[4];
    ssnum[5] = worker[5];
    ssnum[6] = worker[6];/**/

    .../* code that goes here doesn't matter just know it makes a string of chars out the other side.*/

    finline[39]='0';
    finline[40]='0';
    finline[41]='0';
    finline[42]='4';
    finline[43]='3';
    finline[44]='8';
    finline[45]='0';
    finline[46]='3';
    return finline;
    [/code]

    ive tryed useing INT instead of char at the begining of my class but it changes nothing.....
    [Size=5][blue]J[/blue][/size][size=3][red]eripedo[/red][/size]
    [code]If Userclue > 0 then
    msgbox("Woohoo that Makes one")
    end if[/code]
    So... How long do you think you'll be waiting?

  • [code=ffffff]
    [b]char[/b] formatting(char worker[59])
    {
    ...
    return [b]finline[/b];
    }
    [/code]
    Is finline a char?

  • yes its a char[47]
    which may sound dumb considering it takes an input of 50 something and turns it into 47 but thats what the program does...
    [Size=5][blue]J[/blue][/size][size=3][red]eripedo[/red][/size]
    [code]If Userclue > 0 then
    msgbox("Woohoo that Makes one")
    end if[/code]
    So... How long do you think you'll be waiting?

  • : DOH SORRY my bad here we are...
    :
    : [code]
    : char formatting(char worker[59])
    : {
    : ssnum[0] = worker[0];
    : ssnum[1] = worker[1];
    : ssnum[2] = worker[2];
    : ssnum[3] = worker[3];/**/
    : ssnum[4] = worker[4];
    : ssnum[5] = worker[5];
    : ssnum[6] = worker[6];/**/
    :
    : .../* code that goes here doesn't matter just know it makes a string of chars out the other side.*/
    :
    : finline[39]='0';
    : finline[40]='0';
    : finline[41]='0';
    : finline[42]='4';
    : finline[43]='3';
    : finline[44]='8';
    : finline[45]='0';
    : finline[46]='3';
    : return finline;
    : [/code]

    Your function returns a single character, but finline is a character array. So you'll have to return a char *, like:

    [code]
    char *formatting(char worker[59])
    {
    // code here
    return finline;
    }
    [/code]

    Also, where is finline declared? If it's global, that'll work (although it's usually frowned upon), but if it's declared inside of the formatting function, you'll have scope problems. Any variables created on the stack (afaik any ones you don't NEW or MALLOC) will only be valid inside the function. They MAY still be there when the function exits, but that would just be luck, and eventually your program will probably crash.
  • : yes its a char[47]

    char[47] is not char. The return type of your function is wrong.


    IMO, you need to follow dwccgc's advice ASAP. Trial and error is a very inefficient way to learn to program.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories