• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Seanbob11

Member
I'm a but stuck with the trigonometry for this program. The angle between the 2 furtherest stars is supposed to be 2pi/3 or 120 degrees and around a circle with radius 60. This is what I've got so far.

Code:
static void drawFlag(Graphics2D g){
  g.setColor(new Color(8,41,140));
  g.translate(100,100);
  g.rotate(Math.toRadians(200));
  fillStar(g,100,100,8);
}

static void fillStar(Graphics2D g,int x, int y, int r)
{
  Polygon star = new Polygon(
   new int[]{0,22,95,36,59,0,-59,-36,-95,-22},
   new int[]{-100,-31,-31,12,81,38,81,12,-31,-31},10);
  for (int i=0;i<8;i++)
  {
    double a = Math.PI*2*i/16;
    g.translate( 48*Math.cos(a), 48*Math.sin(a));
    g.scale(r/100.0,r/100.0);
    g.fillPolygon(star);
    g.scale(100.0/r,100.0/r);
    g.translate(-48*Math.cos(a),-48*Math.sin(a));
  }

}
 

Kinitari

Black Canada Mafia
So I'm done with school, and I feel like I haven't even really scratched the surface of learning - there are so many things I want to read/learn. And I am forcing myself to get some learning here and there.

One thing I really need to get better with is intermediate to advanced database design/development. I don't think it matters if it's in SQL server or Oracle or whatever, I just want to be more comfortable with the architecture of a good DB.

I really wish there was a KhanAcademy like website for all my programming needs :( I function best with that sort of thing, interactive tutorials that can track my progress/nudge me in the right direction.

As it is right now I feel like there are SO many things I don't know, and so many possible combinations of language, I am a bit lost - do I focus on mastering what I know, or branching out a bit more and covering more of my bases? Sigh.
 

Recarpo

Member
First time posting in here so hopefully somebody can help me out. I'm writing a really simple batch file to do searches on a search engine. right now I just have it doing a looping search using google to search for an incrementing number. The problem is that each search opens a new tab. Any ideas how to keep the searches all confined to one tab? Here's the code I've got.

Code:
@echo off
set /a counter=0
set /p num= Number of Searches:

:loop
if %counter% lss %num% (
start chrome.exe http://google.com/search?q=%counter%
set /a counter=%counter%+1
goto :loop
)
pause
 

mannerbot

Member
So I'm done with school, and I feel like I haven't even really scratched the surface of learning - there are so many things I want to read/learn. And I am forcing myself to get some learning here and there.

One thing I really need to get better with is intermediate to advanced database design/development. I don't think it matters if it's in SQL server or Oracle or whatever, I just want to be more comfortable with the architecture of a good DB.

I really wish there was a KhanAcademy like website for all my programming needs :( I function best with that sort of thing, interactive tutorials that can track my progress/nudge me in the right direction.

As it is right now I feel like there are SO many things I don't know, and so many possible combinations of language, I am a bit lost - do I focus on mastering what I know, or branching out a bit more and covering more of my bases? Sigh.

I would be really surprised if you didn't already know about Coursera, Udacity, and edX, but perhaps one of the advanced classes from these sites would be of interest to you? Unfortunately there doesn't seem to be much in the way of database courses just yet (looks like only two undergraduate level database courses from Coursera), but you could always look at the OCW from various universities.
 

usea

Member
First time posting in here so hopefully somebody can help me out. I'm writing a really simple batch file to do searches on a search engine. right now I just have it doing a looping search using google to search for an incrementing number. The problem is that each search opens a new tab. Any ideas how to keep the searches all confined to one tab? Here's the code I've got.

Code:
@echo off
set /a counter=0
set /p num= Number of Searches:

:loop
if %counter% lss %num% (
start chrome.exe http://google.com/search?q=%counter%
set /a counter=%counter%+1
goto :loop
)
pause

As far as I can tell, there's no way to natively tell chrome to open a url in an existing tab. You have to make an extension for this, or use autohotkey or something. Here's a question/answer about doing what you want: http://superuser.com/questions/1190...command-line-in-a-new-tab-or-an-existing?rq=1

You'd have to put that javascript code he linked into a chrome extension, install it in your browser, and then it'd work the way you want.
 

usea

Member
So I'm done with school, and I feel like I haven't even really scratched the surface of learning - there are so many things I want to read/learn. And I am forcing myself to get some learning here and there.

One thing I really need to get better with is intermediate to advanced database design/development. I don't think it matters if it's in SQL server or Oracle or whatever, I just want to be more comfortable with the architecture of a good DB.

I really wish there was a KhanAcademy like website for all my programming needs :( I function best with that sort of thing, interactive tutorials that can track my progress/nudge me in the right direction.

As it is right now I feel like there are SO many things I don't know, and so many possible combinations of language, I am a bit lost - do I focus on mastering what I know, or branching out a bit more and covering more of my bases? Sigh.
Congrats on being done with school. Don't get overwhelmed with everything you don't know; it'll never change. You'll never know more than the tip of the iceburg. So don't feel like you have to learn everything, or even have a casual understanding of everything, anytime soon. Focus on a very small subset, like say Android programming, or websites in C# (ASP.NET MVC) or maybe write a python script that gets information from some API related to a thing you're interested in, or or \anything\. Just try to make things that you either get paid to do, or you really enjoy. Knowledge will come along the way.

I graduated a year and a half ago, and in that time I've done a very small subset of stuff. Mostly server apps and windows services in C#, sometimes a few other things including database stuff. I know about a hundred times more than I did when I graduated, and I still learn every day.
 

Haly

One day I realized that sadness is just another word for not enough coffee.
The former returns a const int, the latter is a const member function. A const member function "promises" not to modify the objects it operates on. This lets the compiler know that you can safely call this function on const objects.

That's the general idea I think, I'm not 100% certain on this.

(And I don't think there should be parentheses after const)
 

Lkr

Member
The former returns a const int, the latter is a const member function. A const member function "promises" not to modify the objects it operates on. This lets the compiler know that you can safely call this function on const objects.

That's the general idea I think, I'm not 100% certain on this.

(And I don't think there should be parentheses after const)

I was always confused about the const stuff until I read the section on this c++ faq:
http://www.parashift.com/c++-faq/const-correctness.html

thanks to both of you!
 

leroidys

Member
Well, at the base level, you are checking:

x - y <= 0
x + (-y) <= 0

That is, whether the number is less than 0, or equal to 0. You're already checking for one, so check for the other, and decide whether one or the other is true.

I'm fairly certain the answers for all of those are online.........

At least they were 6 years ago.........

Thanks for the suggestions. . It wasn't the 0 case that was tripping me up ( I just switched x and y and !d the result) but the behavior of very large or very negative numbers.

Nothing I was doing would work, because I would get edge cases where the 2's complement of a number would roll over, and not be the right sign, like the 2's complement of -2147483648 being itself.

Also, if I had a really large negative x, and a really large positive y, or vice versa, when I "subtracted" them, it would cause overflow and roll over and give me the wrong answer.

What I ended up doing was first saving the first bit of both x and y as temps, then shifting x and y right by 1 bit and comparing them. If the shifted values were equal, I then checked to see if the least significant bit of (unshifted) x was less than or equal to the least significant bit of (unshifted) y.

Just figuring out how to produce the correct results with only bitwise operators in all cases took me almost 2 hours though... it became a lot clearer when I just wrote down some truth tables and figured out what sequence would give me the right output.
 

Korosenai

Member
So in my class, our instructor gave out some assignments for us to do as a practice test (not worth a grade) and i'm having problems with one.

The question asks us to find all prime numbers between 3 and 100. The hint he gives us says to use to nested loops. He then goes on to say to find out if a number n is prime, to loop from 2 to n - 1.

I've been trying to wrap my head around it, but I have no idea what it means by 2 to n - 1.

I have the outer for loop done to go from 2 and stop at 100, just having problems with the inner loop.
 

Randdalf

Member
So in my class, our instructor gave out some assignments for us to do as a practice test (not worth a grade) and i'm having problems with one.

The question asks us to find all prime numbers between 3 and 100. The hint he gives us says to use to nested loops. He then goes on to say to find out if a number n is prime, to loop from 2 to n - 1.

I've been trying to wrap my head around it, but I have no idea what it means by 2 to n - 1.

I have the outer for loop done to go from 2 and stop at 100, just having problems with the inner loop.

The idea of the inner loop is that it tests all the numbers smaller than n, excluding 1 and itself (hence 2 to n-1) to see whether they are factors or not. If you find one factor, then you know n isn't a prime and so you can print it out and go onto the next number.
 

mike23

Member
Anyone have any experience with selling a piece of personally written software to companies?

I'm writing a program that I think some companies would like to buy. I'm still a few months out from being completed, probably, but I'm curious to see if anyone else has had any luck with something like this. I have no idea what I'll price it at either (or what a company might pay).
 

FillerB

Member
Anyone have any experience with selling a piece of personally written software to companies?

I'm writing a program that I think some companies would like to buy. I'm still a few months out from being completed, probably, but I'm curious to see if anyone else has had any luck with something like this. I have no idea what I'll price it at either (or what a company might pay).

With no idea what it is and no idea what benefit it might bring to companies, how do you expect us to give a meaningful answer? But I can already tell you that it could be tricky to sell unless it's an AMAZING piece of software. Why?

Support.

Companies usually buy software from big software houses or develop it in-house because of exactly that. What guarantee do they have that you will be able to support their employees with problems or be able to fix bugs that arise 1-2 years after purchase?

If you can guarantee them that and your software is both fairly priced and exactly what they need, I can see it happening. Otherwise... tricky.
 

mike23

Member
With no idea what it is and no idea what benefit it might bring to companies, how do you expect us to give a meaningful answer? But I can already tell you that it could be tricky to sell unless it's an AMAZING piece of software. Why?

Support.

Companies usually buy software from big software houses or develop it in-house because of exactly that. What guarantee do they have that you will be able to support their employees with problems or be able to fix bugs that arise 1-2 years after purchase?

If you can guarantee them that and your software is both fairly priced and exactly what they need, I can see it happening. Otherwise... tricky.

Support is a good point. I was considering selling as a yearly license kind of support/customization included or agreed to. The current plan I'm thinking about is to send out emails to HR people with a good overview and a full manual once I'm done to gauge their interest. Maybe ask them about pricing, what they're allowed and willing to spend, etc.

Also, to be fair, I didn't provide specific info because I wasn't really looking for specific advice. I'm more interested in hearing about things other people have gone through.
 

Slavik81

Member
Support is a good point. I was considering selling as a yearly license kind of support/customization included or agreed to. The current plan I'm thinking about is to send out emails to HR people with a good overview and a full manual once I'm done to gauge their interest. Maybe ask them about pricing, what they're allowed and willing to spend, etc.

Also, to be fair, I didn't provide specific info because I wasn't really looking for specific advice. I'm more interested in hearing about things other people have gone through.

What happens when you're hit by a bus?
 

Nesotenso

Member
Codeacademy has added Ruby. I know Ruby has similarities to Perl. I hope to get started on both.

anyone have good additional resources for Ruby and Perl ?

How difficult is perl and how long does it take to get a handle on it ?
 

Roquentin

Member
I took a C/C++ test today at Motorola. Considering that I had almost no contact with C++ in about 5 years (excluding reading this thread from time to time; probably under 1000 lines of code written during that period) I'm happy with how it went. Don't think I'll get the job, though.
 
I took a C/C++ test today at Motorola. Considering that I had almost no contact with C++ in about 5 years (excluding reading this thread from time to time; probably under 1000 lines of code written during that period) I'm happy with how it went. Don't think I'll get the job, though.

I'm sorry to hear that:( I think most programming questions during job interviews are bullshit anyways... Good interviews focus on open-ended problem solving skills and not necessarily formalized design patterns and text-book terminologies. Read the first chapter on how many design pattern books begin and you begin to see why it's stupid to test terminology.
 

Roquentin

Member
I'm sorry to hear that:( I think most programming questions during job interviews are bullshit anyways... Good interviews focus on open-ended problem solving skills and not necessarily formalized design patterns and text-book terminologies. Read the first chapter on how many design pattern books begin and you begin to see why it's stupid to test terminology.
It's all good :) It wasn't a job interview, but Motorola Open Day where you could take the test. And while I'm currently unemployed, it's not important to me to get the job there (the commute is too long). They also had some nice agile development workshops, which I'm glad I attended.
 
d[-_-]b;43060440 said:
Sure, sorry I was just giving of an example of how I code, I suck at this whole practical approach, tried the whole divide and conquer but I suck at tying things together, I try to get a functional piece of code first and work my way from there,
Code:
		public static void main(String[] args) throws Exception {
		URL urldata = new URL("http://www.mangahere.com/mangalist/");
		Document docdata = Jsoup.parse(urldata, 5000);
		Elements ele = docdata.select("div[class=list_manga]").select("li")
				.select("a");

		ArrayList<Manga> lMangaList = new ArrayList<Manga>();

		URL url;
		Manga lManga;
		Chapter lChapter;
		boolean bResume = false;
		for (int i = 0; i < ele.size(); i++) {
			if (ele.get(i).text().replaceAll("\"", "")
					.equalsIgnoreCase("Air Master"))
				bResume = true;
			if (bResume) {
				lManga = new Manga();
				url = new URL(ele.get(i).attr("abs:href"));
				lManga.setTitle(ele.get(i).text().replaceAll("\"", "")
						.replace("'", ""));
				lManga.setIndexLink(url.toString());
				System.out.println(lManga.getTitle());
				Document docdata2 = Jsoup.parse(url, 5000);
				String ogImage = getMetaTag(docdata2, "og:image");
				Pattern p = Pattern.compile("\\d+");
				Matcher m = p.matcher(ogImage);
				if (m.find()) {
					lManga.setID(Integer.valueOf(m.group()));
				}
				lManga.setCover(docdata2
						.select("div[class=manga_detail_top clearfix]")
						.select("img").attr("abs:src"));
				Elements ele2 = docdata2.select("div[class=detail_list]")
						.select("li").select("span[class=left]");
				for (int j = ele2.size() - 1; j >= 0; j--) {
					lChapter = new Chapter();
					lChapter.setTitle(ele2.get(j).text().replaceAll("\"", "")
							.replace("'", ""));
					Elements ele3 = ele2.get(j).select("a");
					String lCheckLink = ele3.attr("abs:href");
					// Parsing Actual Manga
					Page lPage;
					while (lCheckLink.contains("http://")) {
						url = new URL(lCheckLink);
						Document docdata3 = Jsoup.parse(url, 5000);
						Elements ele4 = docdata3
								.select("section[class=read_img]").select("a")
								.select("img");
						lCheckLink = ele4.attr("abs:src");
						if (lChapter.getID().isEmpty())
							lChapter.setID(lCheckLink.split("/")[6]);
						lPage = new Page();
						lPage.setLink(lCheckLink.split("/")[8]);
						Elements ele5 = docdata3.select("span[class=right]")
								.select("a[class=next_page]");
						lCheckLink = ele5.attr("abs:href");
						lChapter.getPages().add(lPage);
					}
					lManga.getChapters().add(lChapter);
				}
		}
	}



Thanks practically the basic idea

I was hoping to get a better idea going forward, trying to be a better programmer in a sense, I look at some of my projects like months after and have trouble recognizing what I was trying to do, try to use Hungarian notation to make it a bit easier, for myself, m -> members, p -> parameters, l -> local variables before there names but sometimes i'm inconsistent when i'm trying to get it to work.

Break this shit up into smaller functions, for one thing. I'm very opposed to huge ass functions and have all of my programmers break their stuff up into smaller functions when feasible. I'm with Bob Martin on this one..."The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that." Function names should be as long as necessary to describe what a function does. Self-documenting code.
 
So I'm done with school, and I feel like I haven't even really scratched the surface of learning - there are so many things I want to read/learn. And I am forcing myself to get some learning here and there.

One thing I really need to get better with is intermediate to advanced database design/development. I don't think it matters if it's in SQL server or Oracle or whatever, I just want to be more comfortable with the architecture of a good DB.

I really wish there was a KhanAcademy like website for all my programming needs :( I function best with that sort of thing, interactive tutorials that can track my progress/nudge me in the right direction.

As it is right now I feel like there are SO many things I don't know, and so many possible combinations of language, I am a bit lost - do I focus on mastering what I know, or branching out a bit more and covering more of my bases? Sigh.

Did you get into design patterns at school? So many interns and programmers fresh out of college haven't even heard of them. Our interns always walk away very thankful to have been with us because they have a leg up on their peers. Good OO programming skills will pay huge dividends in any language, but they have very little to do with simple concepts like polymorphism, etc. - good OO has to do with the interactions of objects to form the so-called "patterns" that really aid in software design.

My recommendation is to read the "Head first" patterns book as an introduction if nothing else. Don't start with the Gang of Four book. Good fundamentals on architecture is a lot more valuable long-term than learning the intricacies of a given language (or knowing many languages). There's room for both in the industry, but the former will translate to just about any job assignment, while the latter is obviously language and environment-specific.

Just my 2c.
 

Tomat

Wanna hear a good joke? Waste your time helping me! LOL!
Need some help with program logic if anyone is interested!

I have to recursively generate and expression tree from a user entered string, but the only parameter I'm allowed to pass to this recursive function is the string (no pointers).

The function header is node * buildTree(string &express); , so it returns a pointer to the binary tree. I'm a little confused since any time I build a binary tree recursively I'm used to passing a pointer along with it as well as the data.

Our professor gave us the Algorithm for building the tree but I'm still not putting two and two together here. The user enters an expression in prefix(polish) notation and we build an expression tree from that. Based on our professors notes the tree is built by doing the follow:
  1. Generate the node with null references to the left and right.
  2. If the "token" is an operand, just return the reference to the (leaf) node
  3. Otherwise
  • a. Recursively generate a tree node and link it as the left subtree
  • b. Recursively generate a tree node and link it as the right
  • subtree
  • c. Return the reference to the resulting (internal) node

I guess the problem I'm running into is that we have to build a tree from a single string and one function call instead of passing the function a single character at a time and using a loop to build the tree. I'm also not sure how to do this recursively without passing a pointer like I have for other binary trees. I have a feeling I'm either over thinking the crap out of this or I really have absolutely no idea what I'm doing.
 

Spoo

Member
Need some help with program logic if anyone is interested!

I have to recursively generate and expression tree from a user entered string, but the only parameter I'm allowed to pass to this recursive function is the string (no pointers).

The function header is node * buildTree(string &express); , so it returns a pointer to the binary tree. I'm a little confused since any time I build a binary tree recursively I'm used to passing a pointer along with it as well as the data.

Our professor gave us the Algorithm for building the tree but I'm still not putting two and two together here. The user enters an expression in prefix(polish) notation and we build an expression tree from that. Based on our professors notes the tree is built by doing the follow:
  1. Generate the node with null references to the left and right.
  2. If the "token" is an operand, just return the reference to the (leaf) node
  3. Otherwise
  • a. Recursively generate a tree node and link it as the left subtree
  • b. Recursively generate a tree node and link it as the right
  • subtree
  • c. Return the reference to the resulting (internal) node

I guess the problem I'm running into is that we have to build a tree from a single string and one function call instead of passing the function a single character at a time and using a loop to build the tree. I'm also not sure how to do this recursively without passing a pointer like I have for other binary trees. I have a feeling I'm either over thinking the crap out of this or I really have absolutely no idea what I'm doing.

Are you allowed to use a helper function? If so, just do what you know and use the helper function to pass the node*.
 

Tomat

Wanna hear a good joke? Waste your time helping me! LOL!
He said we're allowed to use as many functions as we'd like along side the required functions he gave us, so I guess I could try something like that.
 

Spoo

Member
He said we're allowed to use as many functions as we'd like along side the required functions he gave us, so I guess I could try something like that.

It is generally the case that when solutions are recursive, the client calls a simple function with the least amount of data given to get the job done, and the implementation itself calls a helper recursive functions which is not meant to be called directly for the heavy lifting. I'm certain that is what is wanted here.
 

CrunchyB

Member
So this is for use for building a tree for use in say, a compiler?

So you need something like this:

Code:
node * buildTree(string &express)
{
	node *n = new node();
	n.left = buildTree( splitLeftSide( express ) );
	n.right = buildTree( splitRightSide( express ) );
	n.leaf = getLeafValue( express ); // null for non-leafs

	return n;
}
 

CrunchyB

Member
This gives me a bit to work with here, thanks you two.

Good luck.

One more thing, while recursion if well suited for handling these kinds of problems, it is limited by the stack size. So a series like:

x = 1 + ( a + ( b + ( c + ...

...will eventually break your code.

It's probably useful to find out what the exact limit is and mention it in your comments. It's not a problem with real world applications, but it's always good to be on the anal-retentive side :)
 

skynidas

Banned
Hi guys, I was wondering if you could help with something. I have a string that contains this "BBB 2" I want to eliminate the whitespace so that it looks like this "BBB2" . I have tried many things but it still doesn't work, any ideas? I'm programming in Java.
 

leroidys

Member
Hi guys, I was wondering if you could help with something. I have a string that contains this "BBB 2" I want to eliminate the whitespace so that it looks like this "BBB2" . I have tried many things but it still doesn't work, any ideas? I'm programming in Java.

I don't know Java (I know) but it seems like you could just do 4 get char calls and put them into your own 4 length string, usually that function will not count spaces.

Good luck.

One more thing, while recursion if well suited for handling these kinds of problems, it is limited by the stack size. So a series like:

x = 1 + ( a + ( b + ( c + ...

...will eventually break your code.

It's probably useful to find out what the exact limit is and mention it in your comments. It's not a problem with real world applications, but it's always good to be on the anal-retentive side :)

Just to add to this, what you need to watch out for is the growth of a recursive function. If the recursive calls grow linearly (O(x)) you should be OK, but if your initial recursive call is going to make a number of calls that grows exponentially, then your program is going to blow up real fast.
 

Bruiserk

Member
Looking at it, it seems as if you're using the assignment operator in several places (=), instead of the equality operator (==).

"if (current_size = 0)"

"if (current_size = 1)"

etc.

So I'd recommend fixing that first.

That would have definitely been an issue. I booted up Linux and it compiles/runs fine (although not correctly). It must be a compiler issue. I'm doing a fresh install of Cygwin.
 

usea

Member
That would have definitely been an issue. I booted up Linux and it compiles/runs fine (although not correctly). It must be a compiler issue. I'm doing a fresh install of Cygwin.
I don't know a lot about C++, but why would that be a compiler issue? Seems like a problem with the code (especially those assignments instead of comparisons)
 

Bruiserk

Member
I don't know a lot about C++, but why would that be a compiler issue? Seems like a problem with the code (especially those assignments instead of comparisons)

Maybe "compiler issue" is not what I meant to say. I guess I should have said "an issue not related to my code".

It runs fine on Linux. Truth is, I don't know why it is giving me that error.
 

Karl2177

Member
Hi guys, I was wondering if you could help with something. I have a string that contains this "BBB 2" I want to eliminate the whitespace so that it looks like this "BBB2" . I have tried many things but it still doesn't work, any ideas? I'm programming in Java.

You could scan the String with the delimiter as " ".
 
Maybe "compiler issue" is not what I meant to say. I guess I should have said "an issue not related to my code".

It runs fine on Linux. Truth is, I don't know why it is giving me that error.
It was probably the assignment vs. equality thing I mentioned earlier - to explain, look at the older version of your dequeue function:
Code:
void queue::enqueue(int item){
	if(current_size = 0) {
	back_p = new node(item, NULL);
	front_p = back_p;
	++current_size;
}
	if(current_size >= 1) {
		back_p->next = new node(item, NULL);
		back_p = back_p->next;
		++current_size;
	}
}
Note that whenever you run this function, neither of those if conditions are going to be hit. The reason here is, with the assignment operator in the first if statement, you assign the value 0 to current_size. You then check against that value of current_size, and being 0, it will fail. You were doing this, essentially:
Code:
if ((current_size = 0) != 0)
so, you can see why this wouldn't go through.

Now with this information, look at the second function:
Code:
int queue::dequeue(){
	if(current_size >= 2) {
	node* old_front = front_p;
	int temp = old_front->data;
	front_p = front_p->next;
	delete old_front;
	--current_size;
	return temp;
	}
	if(current_size = 1) {
	node* old_front = front_p;
	int temp = old_front->data;
	front_p = NULL;
	back_p = NULL;
	delete old_front;
	--current_size;
	return temp;
	}
	/*if(current_size = 0){
		error("Can't dequeue an empty queue");
	}*/
}
In your test code, you called enqueue 4 times. Assume through the prior explanation that the queue is actually empty after all this time (verifiable by sending the size to cout after each call to enqueue). Calling dequeue, it will skip the first if statement, and then on the second if statement, the value 1 is assigned to current_size, and then the condition if (current_size) is checked. Being nonzero, it goes through:
Code:
if ((current_size = 1) != 0)
And you end up trying to access nonexistent data through a null pointer.

And that's why your program crashed on the first dequeue call, essentially.
 
Thanks for the reply. That was my first time compiling/programming on windows so it was quite new to me. That was a very stupid mistake I made.
Ah np. I've actually had the same problem when I was doing my first few projects in C++...

I think depending on the IDE/compiler you use, some will actually warn you about using = vs == in some places, but it's definitely something to watch out for in general.
 
Top Bottom