Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

opening word file using c++?

Actually, I am new to c+ +. I wonder if it's possible to open word file using c+ +?
Yes, with std:ifstream for reading, std:ofstream for writing or std:fstream for both.

PHP Code

<?php 
#include <string>

#include <fstream>
#include <iostream>

int main()
{
    
std::ifstream fs("file.txt"); // file stream for reading

    
if (!fs)
    {
        
std::cerr << "Error, could not open file" << '\n';
        return 
1;
    }

    
std::string s;

    while (
std::getline(fs, s))
        
std::cout << s << '\n';

    
fs.close();

    return 
0;
} 
(Dec 7, 2018 10:28 AM)knownasknown Wrote:  Actually, I am new to c+ +. I wonder if it's possible to open word file using c+ +?

this is the library i use for word docs, https://github.com/DocxFactory/DocxFactory
http://sunjester.rf.gd - proxies, logins, scanner results
realsunjester, Could you tell me please how to add the library to c++?
(Dec 7, 2018 11:42 AM)incognito04 Wrote:  Yes, with std:ifstream for reading, std:ofstream for writing or std:fstream for both.

PHP Code

<?php 
#include <string>

#include <fstream>
#include <iostream>

int main()
{
 
   std::ifstream fs("file.txt"); // file stream for reading

 
   if (!fs)
 
   {
 
       std::cerr << "Error, could not open file" << '\n';
 
       return 1;
 
   }

 
   std::string s;

 
   while (std::getline(fs, s))
 
       std::cout << s << '\n';

 
   fs.close();

 
   return 0;
} 

That goes for any text based file. I think the OP wants to integrate MS word into an app for either RTF functionality (Bold, color, font size etc).
(Dec 7, 2018 12:34 PM)knownasknown Wrote:  realsunjester, Could you tell me please how to add the library to c++?

what compiler are you using?
http://sunjester.rf.gd - proxies, logins, scanner results
(Dec 7, 2018 10:28 AM)knownasknown Wrote:  Actually, I am new to c+ +. I wonder if it's possible to open word file using c+ +?

What are you looking to accomplish? If you have MS word installed, you can use the COM API documentation. It also depends on if you are looking for cross compatibility also. I assume you are using some form of Windows, right? If so, the easiest and fastest solution to do what you need is via COM API and doing it in C#. Here is an example of how to create a docx file in Word using C# https://code.msdn.microsoft.com/office/H...y-0b9e250a

If you are looking to do C++ for Linux/OS X etc you can use: https://code.msdn.microsoft.com/office/C...d-28938be1

Good luck with whatever the quest is.
(Dec 7, 2018 08:37 PM)realsunjester Wrote:  what compiler are you using?

I am using visual studio 2010 ultimated .
(Dec 8, 2018 11:50 AM)knownasknown Wrote:  I am using visual studio 2010 ultimated .

Code
#pragma comment(lib, "library name goes here")
http://sunjester.rf.gd - proxies, logins, scanner results


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Help] by john ronaldsadAug 18, 2024 05:58 PM 1 144 Aug 18, 2024 05:58 PM
Last Post: Lookdadon
[C#] by madeha elsayedxxxxMay 19, 2020 11:53 PM 4 385 May 19, 2020 11:53 PM
Last Post: Shadow_Cloud
[.NET] by SIM-3602297Feb 19, 2020 09:48 PM 2 192 Feb 19, 2020 09:48 PM
Last Post: gigajew