string variables in C

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

string variables in C

#1 Post by serg1980 » 11 Aug 2023 12:32

hello! I'm switching from pascal to C
I have a question.
How to assign a value to a string variable.
In pascal I did it as follows:

Code: Select all

var str:array[5] of char;//declared a string variable with five characters
.....
str:='hello';//assigned a value to the 'str' variable
how to do the same in C?

Code: Select all

char str[5];
.....
str = "hello";//Error

serg1980
Posts: 44
Joined: 19 Mar 2014 05:58

Re: string variables in C

#2 Post by serg1980 » 11 Aug 2023 14:11

It turned out to do as follows:

Code: Select all

char *str;
.....
str = "hello";
I don't know how correct this is. But it works

Post Reply

Return to “mikroC PRO for AVR General”