tags:

views:

63

answers:

2

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
A: 
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main() 
{ 
char a[] = "ABC";
char b[] = "EDF";
cout<"     "<<a<<"       "<<b;
return 0; 
}
serbanlupu
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