I
I
Ivan Yakushenko2016-04-06 10:02:52
C++ / C#
Ivan Yakushenko, 2016-04-06 10:02:52

How to compare and add strings in "C"?

In the "C" language, there are the following strings, one of which is obtained by typing from the keyboard:

string stringOne, stringTwo;
stringOne = GetString();

First, you need to put the Nth letter from stringOne into stringTwo. Does not work. Perhaps there is some function for this, or does the string need to be converted to char? Next, I check the same stringOne for the presence of various characters, after which I need to determine in which cell they are located and display them.
stringTwo[0] = stringOne[6];
int position, n;
do{
        if(stringOne[n] == "*"){
            printf("%d", position);
        }else n++;
}while(n <= 50);

There is a strncat command that adds strings to each other. Suppose there is still the same stringTwo, in which there is only 1 letter, and there is a stringTemp, in which there are 6 letters, and so the function strncat(stringTwo, stringTemp); for some reason it doesn't work.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Daniil Demidko, 2016-04-06
@Daniro_San

Or maybe it's C++? ... did you try to put a dot after stringOne?

N
Nikita Zubkov, 2016-04-06
@dedi

strncat takes pointers to char (the beginning of the string) as arguments, and in C strings are usually represented as char arrays. Figure out what the string type is for you, because if my memory serves me, it is not in pure C

I
iv_k, 2016-04-06
@iv_k

you seem to have C++ and a std::string class. read the documentation for it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question