Program exited with return code: -1073741819

I want to make a program that reads scientific articles and deletes everything between the parentheses. I can't figure out what is wrong wit it, here are some examples.

A question of key importance to organizational
theorists is, Why do organizations act as they do?
Recently prevailing theories have tended to reify organizations,
variously viewing them as purposeful
(Pfeffer & Salancik, 1978) or hapless (Hannan &
Freeman, 1977) entities.

This works fine however it skips the "or hapless" between the two parentheses

In the field of strategy, explanations
of (and prescriptions for) organizational
moves have centered on techno-economic factors
(Hambrick, MacMillan, & Day, 1982; Harrigan,
1980; Porter, 1980). Even when strategic "process"
is studied, it typically is viewed as flows of information
and decisions, detached from the people involved
(Aguilar, 1967; Allen, 1979; Bourgeois,
1980; Mintzberg, Raisinghani, & Theoret, 1976).

This one works perfectly

For example, economic historians have examined the importance
of learning in the development of new industries and technologies
(Rosenberg 1976), and of the development of formal Research and
Development (R&D) as institutionalized learning mechanisms (Mowery
1981). Learning is argued by industrial economists to affect productivity
(Arrow 1962), and industrial structures (Dosi 1988). Learning within
firms has been a feature of the theory of the firm since Cyert and March
(1963), and learning

Skips everything between (Rosenberg.... 1981), crashes after March and gives me Program exited with return code: -1073741819

It seems to be working on pure whim from what i can tell, did i program a cat by accident?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main ()
{
	//ofstream ofs;
	//ofs.open ("output.txt", std::ofstream::out | std::ofstream::app);
	
	ifstream file1("input.txt");
    
	string read, mod;
	unsigned int i, u;
	
	while(getline(file1, read))
	{
		for(i = 0; i<read.length(); i++)	// copy file to string
			{
				mod += read[i];
	}}
if (i==read.length())
{
	for(u=0; u< mod.length(); u++)	//copy string just in case
	{
		if (mod[u]=='(')
		{
			while (mod[u++]!=')')	// if char is between () skip it
			{
				u++;
			}
		}
		else 
			{ 
				cout << mod[u];	//otherwise show it
}}}}
Line 28/30: You increase u twice which may skip the ')'.

It may crashes if there is no ')' (or it was skippted). Actually it is undefined behavior.

You should at least check for the 0 at the end of the string.
The double increment was the problem, it works fine now.
Thx for the help.
Topic archived. No new replies allowed.