jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Easy there, I don't think anyone was putting the language down at all. I was just offering you a suggestion based on where people have posted questions about it in the past.

I understand what you mean about all of the C "family" being unique languages.

I don't speak for the site in any way shape or form, so I'll defer to Dani for the rest of the discussion.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

@OP I think they've only been answered occasionally, but people have posted Obj-C questions in both C and C++. So, there are higher traffic forums, besides MD, for posts about that topic.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For the others one of the central themes is knowing where to allocate your space for the string and where to delete it.

What is it about the nature of "s" here that creates a problem?

const char* s  = str.c_str(); //memory leak!

Think about the variable's lifetime.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For the first 3, take a look at an ASCII table: http://web.cs.mun.ca/~michael/c/ascii-table.html, what relationship do you notice between the upper and lowercase characters? Hint, chars are 1-byte integers, so you can perform operations on them. See what you can do with those first, those are the most straightforward.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please post what you have thusfar and indicate some specific areas in which you require the most help.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See this article: http://www.codeproject.com/KB/exchange/Exchange2007EWS-Part1.aspx. I think you should be able to add the dll as a reference in C++/CLI and just adopt the syntax.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, I'm on Chrome(9.0.597.107), too. I should have mentioned that. Hmm, but Walt P was able to vote and rep on your post. What's your browser poison, WP?

Edit: It worked for me in this forum.

happygeek commented: rep working now +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes, even the whole forum itself, but it's still not allowing voting/rep on any threads (I've tried hard-refreshing each of those too).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have one of the files from the project selected, then under Project/Properties/Run-Debug Settings/Launch Configurations for '<yourproject>' select your exe file (so probably needs to be built before editing this, but I don't know). Then edit and select the arguments tab.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I just wanted to add, I'd only tried it in those forums (when I tried to edit my post I got a 404)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Even though it may not be related to what you are changing, I'm going to assume it is: voting/rep system doesn't seem to be working in C or C++.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I happened to find a good page on PPM files (http://orion.math.iastate.edu/burkardt/data/ppm/ppm.html). I think I used them a couple of times in college (in prehistory, here).

From what I remember, they are written and read as plain text files. Are you just trying to write out the numerical values of the file to the screen? If so, I would use a combination of fgets to read in the lines and sscanf to parse them into an array of the numeric values. If you mean that you want to display the actual picture, that will be much more involved.

Hopefully you've made some headway with it yourself.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look into .NET Reflector (a legal program that has a free version). It's normally used for C# and VB, but there seem to be some add-ins for C++/CLI that are out there (I've never used any of them, so I can't attest to their validity). You're probably better off trying to retrieve the actual deleted .h files using your favorite utilities package, it will likely be a lot less trouble.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Do you have using namespace System::Net; at the top?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's all good, it was more of a suggestion for the future than anything else anyway.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

what variables am i going to plus and minus?

If you are sorting, you are not adding or subtracting anything. Sort your array in place. Here's one pass through the data(sorting in ascending order):

|6|3|5|9|2|
is 6 > 3, yes, so swap those elements
|3|6|5|9|2|
is 6 > 5, yes, so swap those elements
|3|5|6|9|2|
is 6 > 9 no, so leave the element alone
|3|5|6|9|2|
is 9 > 2 yes, so swap those elements
|3|5|6|2|9|

Since we know that element0 is going to be sorted with respect to element1, start at element1 and repeat the above process. As we go over the list iteration after iteration, that 2 will percolate down to the bottom. That site I gave you is great because it shows you animations. See if you can make some C code out of the pseudocode they provide there along with the details above.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
(int A, int B, int C) //A is money, B is coupons, C is candybars

Allow me to stick my nose in here for a peripheral point, but there's one surefire way to make sure that someone reading your code knows what is money, what is coupons, and what is candybars. Name your variables "money","coupons",and "candybars."

Meaningful names for your variables are important, especially when you get to page 110 of a piece of code and your comment about A,B, and C is many pages back.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have to take you for a beer if you visit Cracow

Sounds good to me!!

For a head start on the mailing stuff check out
See http://www.daniweb.com/forums/thread259176.html (most of that stuff is in the System::Net namespace.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Oh, I didn't even notice that before (sorry), you don't need to make those handles to int32s (System::Int32^), you can just make them ints.

Did you experiment with the lists at all.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

ptr is not the file, stream is the file, ptr is whatever variable you are reading into (really, a pointer to a block of memory, which they malloced in the example at the bottom of that webpage). Size is the "sizeof" of whatever element you are reading (ints, doubles, etc).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think the function you are looking for is fread (the parameters are in a slightly different order, see http://www.cplusplus.com/reference/clibrary/cstdio/fread/). AFAIK, read is an iostreams method from C++.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Maybe that's how your function should see it too. Try

void PrintArray(int[B]*[/B] array[][2], int n)

The first dimension can be blank and the compiler will fill it in for you.

You've got an extraneous star in there, int array[][2] instead of int * array[][2]

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take a look at http://www.sorting-algorithms.com/bubble-sort for the most basic type of sort

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is there a question in there somewhere?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Incidentally, if you think that this approach is outside of the scope of what your instructor expects, certainly revert back to your other approach and use the int array[][2] method. I just wanted you to see the proper way to set up the dynamic 2D array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

May I make a suggestion? Seeing as how this is getting to be painful with the arrays, try using a List<String^> instead. It's a lot more intuitive. It's under the System::Collections::Generics namespace. You can index in, but you can also just use the add method to tack the next string onto the end.

Also, rather than going through a lot of if statements like you have in your last code snippet, make a list (or array lol) of textBoxes and a List of comboBoxes, that way you can use a loop over everything.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Take out line 14, and change "a" to array (walk yourself through the code and try to understand what each of the lines is doing). Substitute in your SIZE variable for the number of rows, and 2 for the number of columns.


and you need to change both lines 6 and 36 to match the line at the bottom of my last post (since you have an int ** pointer, you don't have to worry about passing the second dimension in).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need the array to be static if you do it this way. What line is that Error 1 pointing to?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, you want to open it using ifstream, but since your compiler is pre-standard it may not have that method of the class (I seem to remember this from another poster at one point).

What will probably work (and is also used) is to test that the ifstream object is not null:

ifstream ifs("myfile.txt");
if(!ifs)
   //file didn't open for whatever reason
anu07 commented: worked :) +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

When passing in a 2D array you must specify the second dimension in the parameter: void PrintArray(int array[][2],int n); I should point out that the size of a fixed sized array must be known at compile time, so what you are relying on is likely a compiler extension and is therefore non-standard. You need something like:

int ** a;
a = new int*[rows];
for(int i = 0; i < rows; i++)
    a[i] = new int[cols];    //since you columns is known I don't know if there's a 
                             //shortcut for this step, but I know this works

The added bonus of doing the dynamic allocation is that you can change your function signature to: void Printarray(int ** array,int n) (and you don't have to specify the second dimension).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the exception or error message that pops up?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I tried the following program:
testme.h

#pragma once

ref class testme
{
    public:
        testme(void);
        static cli::array<System::String ^>^ strar = gcnew cli::array<System::String^>(20);
};

Arraytest2.cpp

// ArrayTest2.cpp : main project file.

#include "stdafx.h"
#include "testme.h"
using namespace System;

int main(array<System::String ^> ^args)
{
    testme tm;
    tm.strar[0] = "Test";
    tm.strar[1] = "Me";
    
    
    return 0;
}

(I didn't make a Winforms app, but it's essentially what you are asking it to do)
So, I'm not exactly sure what that error message is directed at. Do you try to give it an i > 19?

I still say the best thing to do is put

cli::array<String^>^ salka;  where you had it, and add

salka = cli::array<String^>(20); to your form's constructor
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you're going to instantiate your array outside of one of the methods (Load, Click, etc.) it must be static. The constructor of the form is a good place to instantiate it, but leave the declaration of it right where it is.

I've heard (though I've yet to get my hands on a copy) that Ivor Horton's book has a good treatment on C++/CLI. Yes, it is a pain in the ass. It was originally meant as a connector between C++ and .NET, but I think it evolved into something that some people use for its own sake. FunctionX has one of the better tutorials for it, but it's getting outdated.

My impression (but don't quote me on it, I'm not an expert, I just find the C++/CLI dialect interesting) is that one of M$'s evil plans is to get people to use C# for their UI (and other coding) with native C++ DLLs where necessary and C++/CLI filling in any middle ground.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No prob. If you haven't been over to MSDN you should check it out as there's every little detail of .NET mapped out (not that I mind answering your questions at all).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have ADD

I'm sure you've got a few other opcodes too, like MUL or something. I'm going to duck to avoid whatever you have just thrown at me.

Me, I do it for the parties at the mansion in Long Island, all the fast cars, speedboats, caviar...a chance to rub elbows with some mathematical models...

...and I suppose there's quite a bit of reward in helping somebody who might have a lot of potential but just doesn't quite get it the right way the first time or helping someone who's "forced" to take a course in CS to realize that the thought process of programming is an important one, no matter what you are going to become.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There may be some non-standard functions to do so in TC++, but I would just try to open it using an fstream object then use the .is_open() method to make sure that it has opened successfully. That's kind of quick and dirty, as I'm sure there are different OS dependent ways to do that, so someone should definitely correct me if I'm off base.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

comboBox1->SelectedIndex will give you the zero-based index of the item you've selected. Probably you were just in a rush, but you want the == instead of = in your line of code above.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You can also call Invalidate(); anywhere within your code to force the Paint() method to run.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You declared double geo=0

Yes, that's very true. Even if he had, though, the result would still be something to the power zero, so that's where the 1 comes from.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Right, so what's anything to the power of 0... = 1

Change 1/3 to (double)1/3

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Won't strcpy() copy the address of the first letter of the string to the hobby pointer,

The compiler knows that hobby is a pointer, but there's no space allocated, so it's not pointing to anything.

strcpy won't keep adding on.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You robbed him of that fun!! Only kidding.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Test the following line: printf("%d\n",1/3); If you provide integers, an integer division will be performed.

Use a cast to make the numerator, denominator, or both into doubles.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use a debugger (or pepper it with cout statements) to see how far it gets in execution. If you can't find it after that, post back and I'll compile it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You still need to know what the errors are. One obvious one is line 21, where did that come from? Also, check what your array Q holds and see what information you are asking it for.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Which one do you actually want, this C++ version (which isn't in the right spot anyway) or the other C version? It's very confusing when things are posted that way.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It would be nice to know what the error was that you are running into. The formatting on this code is terrible. Give http://www.gidnetwork.com/b-38.html a read.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

But I have recieved any answe yet .

Be patient, this is something that is going to have to be looked into by a moderator. One may not be available presently.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Need a standard fifo algorithm

A std::queue would be a good abstraction to look into. I'm not sure how it's actually done, but you could probably look into dissecting the one that the Linux kernel uses.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why are you free'ing y and then returning it?

Good point. I missed that it was the same variable, "the forest for the trees," sorry.