Does C have any tools for doing string addition?

前端 未结 3 604
失恋的感觉
失恋的感觉 2020-12-04 04:31

I\'m making a function that returns the derivative of a function that is represented as a tree like

      /   +    \\
     *          ^
   /   \\      /   \\         


        
3条回答
  •  無奈伤痛
    2020-12-04 04:53

    What you're trying to achieve cannot be done in plain C, because it has no operator overloading. You may use strncat for this, but be advised that this is quite low-level solution that requires you to manage memory manually.

    You can do this cleanly in C++ using std::string or std::wstring objects, which have proper operator+().

    Alternatively you could implement your own string structure with appropriate, object-oriented API.

提交回复
热议问题