Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

exception error breaks too nomemory.cpp

Posted on 2004-04-17
4
Medium Priority
?
237 Views
Last Modified: 2011-09-20
I am getting a exception error and when I break it breaks into nomemory.cpp.  Do I need to clear my memory some how?  any idea what type of things could cause this? hear is my program if it helps

#include "Mstring.h"
#include <iostream>
#include <fstream>

using namespace std;

//Precondition: file is open pass int array[] for row and rowsize for
// array size. Search type is 1 for add 2 for Logg and 3 for Pass
//Postcondition: Will pass back an mstring object with searchType
// in it and \0 if not found
Mstring findStr(char rowIn[],int rowSize,int searchType);

//Precondtion: pass in open output file
//Postcondition: Will output html header to the file
void headerOut(ofstream& fout);

//Precondtion: pass in open output file
//Postcondition Will output html footer to the file
void footerOut(ofstream& fout);

//Precondtion: pass in open output file and address logg and pass
// as Mstrings objects
//Postcondition: will output the html link pass and logg
void addLink(ofstream& fout,Mstring addIn,Mstring passIn,Mstring loggIn);

//Precondition:pass in char array and the size
//Postcondition:will set all the spaces in the array to \0
void clearRow(char rowIn[],int Size);

int main()
{
      Mstring address;
      Mstring pass;
      Mstring logg;
      Mstring empty;
      
      int numrow(0);

      const int size(300);
      char fileName[200];
      char row[size];
      char htmlName[30] = "pornlinks.htm";

      cout << "Enter the name of the file you would like to edit: ";
      cin >> fileName;

      ifstream file;
      file.open(fileName);
      if(file.fail())
      {
            exit(1);
      }
      ofstream fileOut;
      fileOut.open("porn.html");
      if(fileOut.fail())
      {
            exit(1);
      }

      headerOut(fileOut);

      do
      {
            enum type {Address = 1,Pass = 2,Logg = 3};
            file.getline(row,401);
            address = findStr(row,size,Address);
            if(address != empty)
                  logg = findStr(row,size,Logg);
            if(address != empty)
                  pass = findStr(row,size,Pass);
            if(address != empty && pass != empty && logg != empty)
            {
                  addLink(fileOut,address,pass,logg);
                  address = empty;
                  pass = empty;
                  logg = empty;
                  clearRow(row,size);
            }
            numrow++;
            if(numrow == 525)
            {
                  int stop;

                  cout << "pause";
                  cin >> stop;
            }

      }while(!file.eof());
      if(!fileOut.fail())
      {
            footerOut(fileOut);
      }
      fileOut.close();
return 0;
}

//Will set all the chars in the row to \o
void clearRow(char rowIn[],int Size)
{
      for(int i = 0;i < Size;i++)
            rowIn[i] = '\0';
}


//Will output the header for the html file
void headerOut(ofstream& fout)
{
      fout << endl << "<html>";
      fout << endl << "<head>";
      fout << endl << "<title>I love Free Porn</title>";
      fout << endl << "</head>";
      fout << endl << "<body style=\"background-color: darkblue;\">";
      fout << endl << "<h1 align=\"center\" style=\"color: red;\">Dave\'s ****ing Porn Page</h1>";
      fout << endl << "<form name=\"porn\">";
      fout << endl << "<table>";
      fout << endl << "      <tr bgcolor=\"white\">";
            fout << endl << "      <td width=300 align=\"center\">";
                  fout << endl << "      <b>Address</b>";
            fout << endl << "      </td >";
            fout << endl << "      <td width=100 align=\"center\">";
                  fout << endl << "      <b>Logg</b>";
            fout << endl << "      </td>";
            fout << endl << "      <td width=100 align=\"center\">";
                  fout << endl << "      <b>Pass</b>";
            fout << endl << "      </td>";
            fout << endl <<"      </tr>";
}

void footerOut(ofstream& fout)
{
      fout << endl << "</form>";
      fout << endl << "</table>";
      fout << endl << "</body>";
      fout << endl << "</html>";
}

void addLink(ofstream& fout,Mstring addIn,Mstring passIn,Mstring loggIn)
{
fout << endl << "<tr bgcolor=\"white\">";
fout << endl << "            <td width=300 align=\"center\">";
fout << endl << "                  <a href=\"" << addIn << " \" target=\"_new\">" << addIn << "</a>";
fout << endl << "            </td >";
fout << endl << "            <td width=100 align=\"center\">";
fout << endl << "                  <input type=\"Textbox\" name=\"Logg\" value=\"" << passIn << " \"> ";
fout << endl << "            </td>";
fout << endl << "            <td width=100 align=\"center\">";
fout << endl << "                  <input type=\"Textbox\" name=\"Pass\" value=\" " << loggIn << " \"> ";
fout << endl << "            </td>";
fout << endl << "      </tr>";
}

Mstring findStr(char rowIn[],int rowSize,int searchType)
{      
      int searchLen(0);
      int searchStart(0);
      int searchEnd(0);
      char * charPtr;
      int i = 0;
      int j = 1;
      int k = 2;
      int l = 3;
      int z = 0;
      
      if (searchType == 1)
      {
            for (i,j,k,l;l < rowSize;i++,j++,k++,l++)
            {
                  
                  if (rowIn[i] == 'H' && rowIn[j] == 'T' && rowIn[k] == 'T' && rowIn[l] == 'P')
                  {
                        searchStart = i;
                  }
                  if(rowIn[i] == ' ' && rowIn[j] == 'L' && rowIn[k] == ':' )
                  {
                        searchEnd = l -4;
                  }
            }
      }
      else if(searchType == 2)
      {
            for (i,j,k,l;l < rowSize;i++,j++,k++,l++)
            {
                  
                  if (rowIn[i] == ' ' && rowIn[j] == 'L' && rowIn[k] == ':' )
                  {
                        searchStart = i + 6;
                  }
                  if(rowIn[i] == ' ' && rowIn[j] == 'P' && rowIn[k] == ':')
                  {
                        searchEnd = i - 1;
                  }
            }
      }
      else
      {
            for (i,j,k,l;l < rowSize;i++,j++,k++,l++)
            {
                  
                  if (rowIn[i] == ' ' && rowIn[j] == 'P' && rowIn[k] == ':')
                  {
                        searchStart = i + 6;
                  }
                   if(rowIn[i] == '\0')
                  {
                        searchEnd = i;
                  }
            }
      }

      searchLen = searchEnd - searchStart;
      charPtr = new char[searchLen+1];

      if (searchEnd != 0)
      {
            int count = 0;

            for(z = searchStart; z < searchEnd; z++ )
            {            
                  charPtr[count] = rowIn[z];
                  count++;
            }
            charPtr[searchLen] = '\0';
      }
      else
      {
            charPtr[0] = '\0';
      }

      Mstring Address(charPtr);
      
      return Address;
}
0
Comment
Question by:Rackboy
3 Comments
 
LVL 15

Accepted Solution

by:
lakshman_ce earned 150 total points
ID: 10851894
Plz try do some exception handling to find out where the exception occurs.
You can refer to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_core_c.2b2b_.exception_examples.asp

-Lakshman
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10852783
Where does the error occur? Look at the stack after the crash, this will tell you how the function in nomemory.cpp was called. Which operating system are you using?
0
 
LVL 2

Expert Comment

by:sin_
ID: 10877076
do you have any stacktrace?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question