|
-
June 28th, 2012, 09:10 AM
#1
C# To C++
This is nothing big, but i dont understand anything from C++
Could you translate this code to C++ please?
File.WriteAllText(@"test.txt", Regex.Replace(Regex.Replace(File.ReadAllText(@"test.txt"), @"-?(?<!,|\d)(?>\d+)(?!,)", "($&)"), @"-?\d+,\d+", "\"$&\""));
-
June 28th, 2012, 12:03 PM
#2
Re: C# To C++
The rough overview is that it's reading in a file, doing a regular expression find and replace, then writing that data back to the file. It really should be broken into a few different lines to be more understandable. I don't know what version of VS you're using, but if you have 2008 or above, you can use TR1 regular expressions for that. And you can always use good old fopen, fread and fwrite for the File IO. (There's plenty of libraries to use though. I'm pretty sure MFC has a CFile class or something.)
I suggest acquainting yourself with C++ first. And not asking people to just 'translate' code for you. We're here to help, not to do the work for you.
-
June 28th, 2012, 12:49 PM
#3
Re: C# To C++
 Originally Posted by edelis
This is nothing big, but i dont understand anything from C++
You don't understand C++, but you assume it's "nothing big". Also, if you don't understand any C++, what were you going to do with the C++ code (if it were to be translated)?
That one line requires knowledge of C++ file I/O and proper usage of a regular expression library, whether it is <regex> or some other third-party library. To discuss this further in detail is too much for a simple forum response.
Regards,
Paul McKenzie
-
June 29th, 2012, 01:34 AM
#4
Re: C# To C++
Yes, i know what to do with code, but could you please give it to me?
-
June 29th, 2012, 02:24 AM
#5
-
June 29th, 2012, 02:54 AM
#6
-
June 29th, 2012, 12:43 PM
#7
Re: C# To C++
 Originally Posted by edelis
???
What's the problem? You were given a link to C++ code that processes a regular expression. As a matter of fact, it is a full example of usage of the class.
Did you think that one line of code in C# means one line of code in C++?
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|