Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert C# to C++ [closed]

Tags:

c++

c#

mixing

Could someone please help me to convert C# to C++? here is an example:

using System;
using System.Net;
using System.Text;
using System.IO;
using System.Threading;
namespace read_website
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                DownloadString("http://www.xxx.asp");
                Thread.Sleep(100);//update every 100 millisecoand 
            }
        }

        public static void DownloadString(string address)
        {           
            WebClient client = new WebClient();
            string website = client.DownloadString(address);
            get_Current_X1_value(website);
        }

        static void get_Current_X1_value(string web)
        {
            int x = web.IndexOf("Current X1 value:");
            string part1 = web.Substring(x, 100);
            string[] array = part1.Split('>', '<');
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].Contains("Current X1 value:"))
                    Console.Write(array[i]);
                if (array[i].Contains("W"))
                    Console.WriteLine(array[i]);
            }

        }
    }
}

Actually as it is complicated to mix C# and C++ on unix, I am trying to convert C# to C++

like image 580
make Avatar asked Jan 10 '11 20:01

make


People also ask

How do you convert Celsius to Fahrenheit easy?

To convert temperatures in degrees Celsius to Fahrenheit, multiply by 1.8 (or 9/5) and add 32.

What is the formula to C?

The relationship between Fahrenheit and Celsius is expressed with the formula, °C = (°F - 32) × 5/9; where C represents the value in Celsius and F represents the value in Fahrenheit.


2 Answers

I'm using C# to C++ converter time to time. It's really great for snippet conversion from c# to c++ or c++/cli.

like image 196
igorushi Avatar answered Sep 29 '22 14:09

igorushi


Learn C#, learn C++, and spend a lot of time rewriting.

Or use PInvoke from the C# assembly to call into a C++ dll.

Or write managed C++ and compile with the /clr switch. The resulting assembly can be referenced and used from C# projects.

like image 30
Trystan Spangler Avatar answered Sep 29 '22 14:09

Trystan Spangler