touppr() problems

i=0;
while(sentence[i]) /*ciclo per implementare la funzione toupper()*/
{
c=toupper(sentence[i]);
write(fp,c,1); /*scrive su file*/
printf("%c",c);
i++;
}

could this part of code be right?? if not why?

it doesn't write on file, and don't uppercase the sentence or the char c!!
[code] Your code goes here [/code]
The sentence will not be modified (the parameter is copied)
It's not writting to the file because write() is a member function of ostream not a straight function. See here:

http://www.cplusplus.com/reference/iostream/ostream/write/

So you would need to write it tied to an active ostream like in the example above.

I'm not sure why it wouldn't output the uppercase letter. I'll have to look into it more.
Either what Computergeek01 said or http://www.cplusplus.com/reference/clibrary/cstdio/fwrite/
there is however no write(FILE*, char, int).
Note also that in both fwrite and ostream::write, data has to be passed by a pointer while you try to pass it by a char value.
oh hamsterman tnx i don't understand how i could use that "method"..

tnx to all so this forum really it works!!
Topic archived. No new replies allowed.