convert a VB code to CPP [Manual]

Hello . I'm new in this forum
I wanna convert this code [Visual Basic] to C++ , but I don't know that what do the lines 5,10,11 and 16 .
There is some functions that i don't know what's the equivalent of that's on C++ !
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
For i = 1 To 9999999

Dim S As String
Dim TMP As String
S = Str(i)
Dim Sum As Double

For j = 1 To Len(S)
TMP = Mid(S, j, 1)
If (TMP <> " ") Then
Sum = Sum + (Val(TMP) ^ Val(TMP))
End If
Next j

If (Sum = i) Then
List1.AddItem (Sum)
End If

Sum = 0

Next i

End Sub


it's true that the equivalent of TMP = Mid(S, j, 1) for c++ is tmp = s.substr(0, j);
how can i do it ? please help me :/
Sorry for my bad English.
Last edited on
In line 5 you convert an int intoo a string and assign it into a string called S.
Line 10, you check if substring called TMP is different from a space " ", btw <> is != in c++.
Line 11, you convert the number from TMP string into integer, multiplie it with itself and add it to Sum, which is a double.
Line 16, "List1" was not defined in your sample code, but I assume it's some kind of a vector where you can push items.

I don't think converting from vb to c++ is difficult since those aren't that different, apart from syntax.
Topic archived. No new replies allowed.