Reputation: 29
So I'm trying to take the second to first character from Expresie
which is a char array and copy it into a char variable, and then use the strcat
function to place that variable at the end of another char array Stiva
. this is the code:
int SHIFT(char Expresie[], char Stiva[], int x)
{
char a=Expresie[0];
strcat(Stiva,a);
And this is how they are defined in main:
int main()
{
char Expresie[100];
char Stiva[100];
The problem is that when i run it it says : invalid conversion from 'char' to 'const char*'
Upvotes: 0
Views: 154
Reputation: 66371
strcat
appends strings, not characters - it wants a pointer to the first character of a "C string", not a single char
.
The simplest way to do this is to add the character directly at the end yourself (assuming that there is room, of course):
int SHIFT(char Expresie[], char Stiva[], int x)
{
char a=Expresie[0];
size_t length = strlen(Stiva);
Stiva[length] = a;
Stiva[length+1] = 0;
// ...
Upvotes: 1