How to write into an objet

Good evening,

I am trying to give a value to an objet wihtout success.

I declare it like this:

 struct MyFix {
 //float field1;
   //byte field2;
   char position[FIXSIZE];
 };

Then I create an object

MyFix obj;

But now I would like to give a value to position

char str[]="totototo";
obj.position = str;

Then I print it

Serial.println(fix.position); and it should pirnt:

totototo

My problem is here

obj.position = str;

it does not work and I also tried

obj.position->str;

Which is the good way to attribute a value to an object?

Arrays can't copy themselves: http://arduino.land/FAQ/content/6/30/en/how-to-copy-an-array.html

You could use strncpy

char str[]="totototo";

strncpy(obj.position, str, FIXSIZE);

Hello

Thank, yes, it what I just found

http://www.cplusplus.com/reference/cstring/memcpy/

I did like this

memcpy(obj.position,fix,strlen(fix)+1);

But what's the difference between memset and strcpy

I think strcpy() does not add a \0 and the end

I think strcpy() does not add a \0 and the end

You think wrong. The main difference between memcpy() and strcpy() is that strcpy() figures out how much data to copy. You have to tell memcpy().

Thank for this :)