Problemer ang. arrays!
#include "stdafx.h"ofstream write ("output.txt");
char input[256];
char funstart[256];
char funend[256];
int main(int argc, char* argv[])
{
if (!write.good())
{
return 0;
}
cout << "String -> ";
cin.getline(input,256);
cout << endl;
for (int i=0;i<strlen(input);i++)
{
funstart[i] = input[i];
cout << funstart << endl;
write << funstart << endl;
}
for(int x=strlen(input);x>0;x--)
{
funend[x] = funstart[x];
cout << funend << endl;
}
return 0;
}
//--->
Første del virker fint med at lægge et bogstav til min buffer indtil den bliver fyldt ud, men det andet virker ikke hvor jeg vil reducere den ned igen.
Hvordan løser jeg det? Jeg skulle gerne have et resultat som dette, hvis input var "hello":
h
he
hel
hell
hello
hello
hello w
hello wo
hello wor
hello worl
hello world
Lidt hjælp tak! :)