@interface ActiveDirectory : NSObject
{
char nome;
char sobrenome;
int num;
}
C character (char) variables can only store a single character. For instance, this would work:
char nome = 'a';
char sobrenome = 'z';
C
strings, on the other hand, must be used in one of three ways. For example:
char *cp = "test";
char cp2[] = "test2";
char cp3[] = { 't', 'e', 's', 't' };
printf("%s %s %s\n", cp, cp2, cp3);
The first is simply a character pointer.
The second is a character array.
The third is also a character array, but shows that each letter is an individual character (char) (hence why it is called a character array).
So, to answer your question, to fix your code you should change your instance variable declarations in your @interface to this:
@interface ActiveDirectory : NSObject
{
char *nome;
char *sobrenome;
int num;
}
or this:
@interface ActiveDirectory : NSObject
{
char nome[];
char sobrenome[];
int num;
}
(you can mix and match between using *nome and nome[] any way you like.
To reiterate, the reason why your code is not working is that char variables can only store a single character (one letter, symbol, etc.).
