Im sure i have a syntax issue or just not doing something right as i am new to c++.. i am generating an error code in my program ... here is my code

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <string>
#include <string.h>

using namespace std;

int main(int argc, char *argv[])
{

// Opens the Text File in is my "cin" in essence
ifstream in ("C:\\Documents and Settings\\HP_Administrator\\Desktop\\test.txt");

//both arrays in which i will place the text from the text file. "registers" will get the first 8 lines of numbers and memory will get the remaining lines of numbers
 int registers[7];
 int memory[4000];
 int i;
 int x;
 string s;
 string string;
 
 
 
// read registers until eight integers are read
    i = 0;
    while (getline(in, s)) {
          if (stringstream( s ) >> registers[i]) i++;
          if (i == 8) break;
          }
          
          // read memory until the end of file
          i = 0;
          while (getline ( in, s )) {
                if (stringstream( s ) >> memory[i]) i++;
                }
                
                cout << "(:----------REGISTERS----------:)" << endl;
                cout << " " << endl;
                for (i=0; i<8; i++)
                cout << "Registers   : " << setfill ('0') << setw (6) << registers[i] << "          -:)" << endl;
                cout << " " << endl; 
                cout << "(:-----------MEMORY------------:)" << endl;
                cout << " " << endl;
                for(i=0; i<14; i++)
                
                cout << "Memory Dump : " << setfill ('0') << setw (6) << memory[i] << "          -:)" << endl;
                cout << " " << endl;
                cout << "(:-----------------------------:)" << endl;

if (memory[i].substr(0,4)=="0000")
(
cout << "See Groups 3 & 4 " << endl;
) 
       
                in.close();

the error generated is as follows:

in function 'int main(int, char**):'
'substr' has not been declared
request for member of non aggregated type before '(' token


any help is greatly appreciated thank you very much

substr() isn't a member function of an int. An int is a primitive, not a class. Also, you can't really call a substring on an integer.

>>if (memory.substr(0,4)=="0000")

memory is an array of integers which of course don't have methods.
[edit]^^^ what Shawn said[/edit]

so i should have a string array instead

It depends on what you want to do with that particular operation. You might need a string or you could just use modulus.

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.