I want to print two strings (say "ABC" and "DEF") with 5 space characters before "ABC" and that the second string will start 7 characters after the beginning of the first string.
+2
A:
I suspect you're looking for the width() method:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string abc = "ABC";
string edf = "EDF";
cout.width(8);
cout << abc;
cout.width(7);
cout << edf;
return 0;
}
Hans Passant
2010-03-14 18:53:43
A:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
char a[] = "ABC";
char b[] = "EDF";
cout<" "<<a<<" "<<b;
return 0;
}
serbanlupu
2010-03-14 22:00:51
Not correct. b is printed 7 spaces after the __end__ of a here. It should be printed 7 spaces after the __beginning__ of a.
Wallacoloo
2010-03-14 22:06:11