So basically, as of now I have a word and numbers that i am trying to space out for output (the code is in a text file)

it's like
"HEY10001101" when it's supposed to look like "HEY 10001101".
i have the "HEY" stored as an "string command" and the number stored under as a op1 array (i is an int, so that i could store each # in a FOR loop).

how can i print so that i can choose to put the op1 wherever i want?

i have the "HEY" stored as an "string command" and the number stored under as a op1 array

I'm really not sure what you're trying to say there, but it only makes sense in the context of your program. Please post your code.

You write

cout <<op1[i];

And I agree with jonsca, post your code here

okay, well i figured it out that it just needed setw()

it's basically,
i have a txt file
"HEY 10001011 10000111"
and i need to take each of the 3 parts and input them. So far, i have the "hey" and the "first binary" stored into an array, how do i store the second? would it be another binary int?

#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

/*===============================================================*/

void greeting();			/* header */
void columntitle();         /* table header */
void cnot(int copy[], int i, int op1[], const int SIZE); /*call for "NOT"*/
void cand(int copy[], int i, int j, int op1[], const int SIZE); /*call for "AND"*/
void cor(int i, int j, int op1[], int op2[], int copy[], int result[], const int SIZE); /*call for "OR*/
void cconvert(int op1[], int SIZE, int result[]); /*call for "CONVERT"*/

/*===============================================================*/

int main()
{
const string fileName = "small.txt";    /* set file to be called */
const int BASE = 2;						 /* set BASE constant */
const int SIZE= 7;						 /* set SIZE constant */
int op1 [SIZE];							/* array size of OP1 set to SIZE */
int op2 [SIZE];							/* array size of OP2 set to SIZE */
int copy [SIZE];						/* array size of copy set to SIZE */
int result [SIZE];						/* array size of RESULT set to SIZE */
int power (int, int);					/* for POWER function */
int i;									/* runs */
int j;
char ch;								/* used to retrieve commands from file */
fstream inFile;							
string command;			

greeting();								/* call header */
	
columntitle();							/* call table header */


inFile.open(fileName);					/*open the file for output */

while(inFile)							/* while inside of the file */
{
	while (inFile >> command)			/* store file data into command */
	{

		cout << setw(11) << command;

			for (i=0 ; i<SIZE ; i++)
			{
			inFile >> ch;
			op1[i] = static_cast<int>(ch)-48;
			op1[i] = ch;
			cout << ch;
			}

	if (command == "NOT")
	{
		cnot(copy, i, op1, SIZE);
	}
	
	else if (command == "AND")
	{
		cand(copy, i, j, op1, SIZE);
	}

okay, well i figured it out that it just needed setw()

it's basically,
i have a txt file
"HEY 10001011 10000111"
and i need to take each of the 3 parts and input them. So far, i have the "hey" and the "first binary" stored into an array, how do i store the second? would it be another binary int?

Exactly the same as the first. Why would it be different?

i thought it might since both numbers are on the same line in the text file.

so i would keep it the same just copy it twice? or would I just change the sizes of the for loops?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.