Start New Discussion within our Software Development Community

If I remember correctly from C# to C++ the following should convert into the second following. I need to create a console application that will output the physical address of the main interface on a user's computer. This in my experience seems to always be the second interface in the array of network interfaces within the NetworkInformation namespace.

using System.Net.NetworkInformation;

namespace test
private class testclass
private NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
private string pa = "";

private void main()
// Not 100% sure straight from memory but I know it's not that hard to find.
pa = interfaces[1].PhysicalAddress.ToString();

Converts to?

#include <iostream>
#include <string>

using namespace std;
using namespace System::Net::NetworkInformation;

int main()
// In c# * is for pointers and something tells me I'm confused. :(
NetworkInterface* interfaces = NetworkInterface->GetAllNetworkInterfaces();
cout << interfaces[1]->PhysicalAddress->ToString();

Please note, I haven't used C++ in years and don't remember hardly anything from it. I can do my basics that's about it. Most of the syntax still trips me up quite often.

float x1, x2;
cout << (int)(x1 / x2);

Those are what I consider basics, so any help here is appreciated. I'm taking a C++ class and don't have my class book. So any way that I can learn the material I'll take it.


This question has already been answered. Start a new discussion instead.