In the past I have programmed in BASIC but am trying to learn some c++.
So I might write a program in BASIC and then translate it to c++.
But BASIC and C++ seem to deal with strings differently?
This program extracts strings between a comma/space and a semicolon.
The BASIC version works but there seems to be a problem with the string arrays in the C++ version?
dim as string s1 'main string
dim as string s2(10) 'save extracted strings
dim as integer count 'number of saved strings
dim as string temp 'temporary string
dim as integer flag 'start of reading string
s1 = "Hello, my name is, Nathan; It's, a pleasure, to meet you;"
for i as integer = 0 to len(s1)-1
if s1[i] = asc(",") and flag = 1 then
temp = ""
flag = 0
else
flag = 1
end if
if flag = 1 then
if s1[i]<> asc(";") then
temp = temp + chr(s1[i])
else
print temp
s2(count) = temp
count = count + 1
temp = ""
flag = 0
end if
end if
next i
sleep
And its conversion to C++ which crashes when I uncomment lines 30 and 31
//s2[count] = temp;
//count++;