Переписать код с C++ на С(си) - C (СИ)

Узнай цену своей работы

Формулировка задачи:

Нужно переписать код с C++ на С(си) код. У меня ничего не получается... помогите, пожалуйста
#include <iostream>
#include <string>
 
using namespace std;
 
int main ()
{
    setlocale(0, "");
    string str, str2, str3, buf;
    
    cout << "Введите строку: ";
    getline(cin, str);
 
    cout << "Введите разделитель: ";
    getline(cin, buf);
    
    unsigned pos = str.find(buf);
    str2 = str.substr (0,pos);
    str3 = str.substr (pos); 
 
    cout << "Часть первая: " << str2 << "\nЧасть вторая: " << str3 << endl;
                                           
    system("pause");
    return 0;
}

Решение задачи: «Переписать код с C++ на С(си)»

textual
Листинг программы
if (pos != NULL)
  {
    strncpy(str2, str, pos - str);
    str2[pos - str] = '\0';
    
    strncpy(str3, str + (pos - str), strlen(str) - (pos - str));
    str3[strlen(str) - (pos - str)] = '\0';
  }

Оцени полезность:

11   голосов , оценка 4.182 из 5