Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What are you entering for Input (line 27)? And what are the command-line arguments you are using (argv[])?

I tried to run your program and it crashed upon startup, the reason is that it takes up too much stack space. All those huge arrays are just too much. Move lines 14 and 16 up above main() into global space and the program will run.

line 40: That is a memory leak.

Ignore that comment -- your program is freeing memory correctly.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Line 24 is unnecessary because the string is already null terminated. Also, you are null terminating the string in the wrong place.

line 38: illegal statement. Must be arg[++count][0] = '\0';

line 40: That is a memory leak. tokens is not a simple block of memory. You have to free() each of the pointers individually (see line 71).

line 42 is unnecessary because line 44 strcpy() will start at the beginning of the character array anyway.

line 51: you might try typcasting the last parameter
_spawnv(_P_WAIT, prog, (char**)arg))

line 62 and 69: sizeof(*result) will ALWAYS be 1, so using sizeof() there has no value.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Have you tried ComboBox.FindString() ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

cout is defined in <iostream> header file. As a beginner, don't try to read iostream header file -- it's a big mess. Just be aware that cin and cout are declared in iostream. If you want to do file io then use fstream, ifstream and ofstream classes. Trying to follow the header files can ruin your brain.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you don't know what namespaces are then you need to read a good tutorial because namespaces are fundamental to c++ language. Namespaces were invented to keep from getting name conflicts from one file to the next, that was a big problem in C language. For example, file A.h might declare a struct named foo, and file B.h might declare another structure with the same name. If both files are included in the same *.cpp file then there is a name clash. Namespace helps prevent that problem.

All (or most) standard C++ header files are under the namespace called "std". So when you write using namespace std; you are telling the compiler to use everything in that namespace regardess of where it comes from. In small pograms like you might write in school that is not a big problem, but in large professional c++ program it can become a problem. There are a couple alternate ways of coding it, such as using std::cin; or just writing std::cin << "Hello World\n";

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe paper is better if you are in a place where there is no electricity, such as in a small boat in the middle of the ocean. Kindles need electricity to recharge the batteries.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't think you want to use a Kindle in a hot tub:) A little like using a hair drying in one. Not very smart thing to do.

either forum would be a reasonable place to ask

Not really -- the question is not related to compute languages.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I prefer ebook because I can change the font size to whatever I like, because ebooks aren't as heavy as paper books, and because people don't chop down any trees to create ebooks.

iConqueror commented: agreed +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Really???

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, but the numbers are all in ascending order if you read the lines from top to bottom, ignoring the arrows. It should be rather trivel to add the arrows.

1 2 3 4 
5 6 7 8
9 10 11 12

The flaw in my approach is if the data is in some random order in the output

1 4 2 3
9 10 7 8
11 5 6 12

If that is possible, then you can't use my suggestion.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 121: You can not test two floats or doubles for equality due to possible rounding errors in memory variable. For example if you assign the value 5.5 to a float, in memory it might actually be 5.500001.

One way to handle that is to use integers instead of floats. So if you want 1 decimal place then multiply the float by 10 and assigne it to an integer. Then you can safely use equality tests on the integers.

Here is another thread on that very topic.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 240: Suggestion: Save yourself a lot of grief by shortening that path down. In Visual Studio you can move the projects to another folder. I always put projects in a folder directly off c:, such as c:\dvlp That makes it a lot easier to specify specific project paths.

line 244: how do you know there will be at least 10 lines in the file? What if there are only 5, or there are 50? A more general way to code it without knowing beforehand how many lines are in the file is like this:

int i = 0;
while(getline(inFile, line))
    {
        list[i] =::atof(line.c_str());
        x.InsertItem(list[i]);
        ++i;
    }

Or even better yet

    int i = 0;
    while(infile >> list[i] )
        {
            x.InsertItem(list[i]);
            ++i;
        }

Why do you need float list[10] ? You can just insert it directly without first reading into list.

    float n;
    while(infile >> n )
        {
            x.InsertItem(n);
        }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That isn't, what i said was to sort it in ascending order because the final output is in ascending order.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Of course there is -- look at the expected output, it's in ascending order from top to bottom. But maybe that is just a coincidence???

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Once you get the 12 numbers why not sort them in ascending sequence then print them out like normal? Or is that considered cheating?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what is the expected output?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have to include stdlib.h

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Do you have a question?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Like so,this works for me:

You need a different compiler.

I think it is possible to do that

You can not have one function inside another function in either C or C++ languages. You can declare a function prototype inside a function, but the function itself has to be coded outside any other function.

#include <stdio.h>
#include <string.h>

int main()
{
  char name[5][50];
  int numofname = 5;
  int i;

void getname(char name[][50],int numofname); // this is ok

 for( i = 0;i < 5; i++)
   getname(name,numofname);

 for( i = 0;i < numofname; i++)
    printf("%d : %s\n", i, name[i]);

  return 0;
}      
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is it correct? No. You can't nest one function inside another.

    #include <stdio.h>
    #incluede <string.h>
    void getname(char  name[][50],int num)

    int main()
    {
        char name[5][50];
        int numofname = 5;
        getname(name,numofname);
     }      

     void getname(char name[][50],int numofname)
     {
            for(int i=0;i<numofname;++)
            scanf("%[^\n]",name[i]);
     }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What are you confused about?

for i ← 0 to n − 1 do

In c++ this would be for(i = 0; i < n-1; ;)

or it could be coded as a do loop

int i = 0;
do {
  // something
} while( i < n-1);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem with that is FindFirstFile and FindNextFile know nothing about std::vector, or even c++. Those are just C functions. In order to make your suggestion work you would first have to resize the vector with enough entries to hold all the files that those two C functions might return, and you have no way of knowing that without first counting the files. Of course you could just resize the vector with some arbitrarily large number in hopes that it will be enough.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't unless you also write your own file system, which I doubt you will want to do. The CD command is only good while the program is still running. After the program terminated the current directory reverts back to whatever it was before the program started. AFAIK there is no way to change that behavior.

The program you posted in another thread about this problem should work as far as I can tell. I never had a problem with chdir() unless I was giving it an invalid path.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is the start of the function, now all you have to do is create two nested loops. The outermost loop iterated from 0 to 6 which displays the compainies, and the inner loop counts from 0 to 4, displaying each of the sales on the same line as the company name. Each of the columns should be separated with a space, tab, comma, or some other separator of your choice.

ofstream& writeData(ofstream& out, char companies[6],char sales[6][4])
{

   return out;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

On my computer the file is here: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib

If you also have VS 2010 installed on the same computer there may be a conflict. See this related article

I have 2013 Pro edition installed on my computer and don't have that problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

loops are the hardest thing.

Yes they do seem difficult when you are first learning -- But, like most everything else you do, a little practice helps clarify things in your head. Been there, and done that too.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to start a new loop on line 21, you can't reuse the same loop because the value of i counter is now beyond the bounds of the array. So just copy line 12 to between lines 20 and 21.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post code

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use a loop very similar to the one I posted above except use cout instead of cin.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Start out by coding a very simple loop

int i;
for(i = 0; i < 5; i++)
{
   // code goes here
}

that goes on line 10, after students declaration. Now move lines 14-18 inside the loop and use the i counter to index into student array, like this:

cin >> students[i][0];

It would be a lot better to use a structure or a class, but you probably have not learned those yet. So arrays like you have them will work.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem might be line 61 -- al_draw_text(...), I don't have that library installed so I couldn't call it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem must be soemthing else in the program that has corrupted stack or program memory. The code below works ok for me

#include<string>
#include<vector>
#include<iostream>

using namespace std;

class Settings
{
private:
    vector<string>board;
protected:
public:
    Settings();

    bool loadAndDrawFont();
};



Settings::Settings()
{
    board.push_back("050106007");
    board.push_back("620054090");
    board.push_back("000908002");
    board.push_back("300000568");
    board.push_back("080605020");
    board.push_back("546000009");
    board.push_back("700502000");
    board.push_back("030840016");
    board.push_back("800301040");
}

bool Settings::loadAndDrawFont()
{

    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (board[i][j] == ('1'))//this is the line thats the problem
            {
                cout << board[i][j] << '\n';
            }
        }
    }
    return true;
}
    int main()
    {
        Settings s;
        s.loadAndDrawFont();
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have a tablet for a couple years now -- almost complete waste of money. The only thing I use it for is to play a few games on occasion. One time I thought I could set the tablet up so that I could watch TV on it through my TV provider -- paid a few dollars to get the TV receiption rebroadcase onto my wifi then receive the wifi signal to the tablet -- it worked -- but it was sooo slow that it was nearly unwatchable. Good idea, but it's just not fast enough.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My PC has a lot of external devices connected to it, I don't see how a tablet could possibly do that. The tablet I have has only one port -- to tether to a PC or recharger.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Like I said, that won't compile for the reason you just posted. In your program one of the parameters to the friend function must be a reference to LargeInteger class. If that is not needed, then don't make it a friend function.

So I need to use *&, what's the name of such construct, pointer address, and how is it different from a pointer(

The & makes it a reference to a pointer, something similar to **. Since str1 and str2 are both pointers, you can do away with the & operator and just pass the pointers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

if (str != str2)

Since the memory for str and str2 are allocated at runtime they two address will never be the same. Lines 10 and 14 are reversed, line 8 will always be true so there is nothing wrong.

Since str1 and str2 are really pointers, here is how to write the code

class CustomString
{
public:

    std::vector<string> vec;
};



class LongInteger
{

    friend bool operator== (CustomString *&str1, CustomString *&str2);
    friend bool operator!= (CustomString *&str1, CustomString *&str2);


public:


private:
    vector<string> vec;

};

bool operator!= (CustomString *&str1, CustomString *&str2)
{
    std::vector<string>::iterator s2 = str2->vec.begin();



    for (std::vector<string>::iterator s = str1->vec.begin(); s != str1->vec.end(); ++s)
    {


*
        if (*s2 == *s)
        {
            cout << *s2 << *s << endl;

            return false;
        }


        ++s2;
    }

    return true;
}

int main()
{
    CustomString *str = new CustomString("helloworld");

    CustomString *str2 = new CustomString("helloworld");


    if (str != str2)
    {
        cout << "everything is ok" << endl;
    }
    else
    {
        cout << "something is wrong" << endl;
    }

    return 0;
}

That still won't compile because the two operator lines in class LongInteger are incorrect.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How you write it is a little unconventional, but should still compile ok. You just have unnecessary parentheses.

for(std::vector<string>:: iterator s = str1.vec.begin(); s != str1.vec.end(); ++s)

I can't really say what the problem is without seeing the whole program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 7 is incorrect -- instead of ++i it should probably be ++s.

does line 14 show that *s and *s2 are the same strings?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 12 and 15 are wrong. According to line 27 the parameter to multiply() is not a callback function, but just a simple integer.

int multiply(int a, int x)
{
    int r = x; 
    int e = a * r;
    return e;
}

If you really intend to pass the add() function as a parameter, then do something like this. Note that since add() takes two parameters, main() must supply those values on line 27, OR multiply() must supply them itself.

int multiply(int a, int(*x)(int, int),int b, int c )
{
    return a * x(b,c);

}   

If you want main() to supply the two parameters to main(), line 27 would look like this:

cout << multiply(10,add,2,5) << endl;

Otherwise if multiply() is to supply the two parameters

int multiply(int a, int(*x)(int, int) )
{
    return a * x(2,5);

}   

cout << multiply(10,add) << endl;
furalise commented: Well constructed answer. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sorry, we don't do you homework for you. Post your attempt to solve the problem then ask specific question(s) about what you don't understand.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are missing some brackets. statements that are two or more lines require brackets, like this:

if (Exempt == 'Y' )
{
    cout << "Gross wages = " << (hoursWorked*hourlyRate) << endl;
    cout << "NO TAXES DEDUCTED";
{   
else if (Exempt == 'N')
{
    cout << "Gross wages = " << (hoursWorked*hourlyRate) << endl;
    cout << "Wages after taxes = " << (hoursWorked*hourlyRate)-((hoursWorked*hourlyRate))*0.18 << endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 40: you forgot the class name before function name. float Student::setEnglish(

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For version, see here

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 50 should probably be the same as line 38.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you want all the characters on the same line then remove the newline character '\n' from the cout statement(s).

The second comparism doesn't seem to come out well too

Line number please???

I was told its completely C++

You mean NetBeans? It's an IDE that's used for several different languages.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 26 has two problems:

position should not be decremented on line 26, decrement it after line 29.

the loop should continue while position > 0 instead of > 1.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

SetParents() does not need a reference to a pointer -- just the pointer

_clients->at(FreeIdx).GetPlayer()->SetParents(this, __clients->at(FreeIdx));

When passing a poitner by reference the & operator is not used in the actional function call, only in the function prototype and function header. The & in the actual function call makes it a pointer to a pointer, not a reference to a pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm running the same version number of Chrome you are.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you running Chrome under Windows or *nix? In Windows 8.1 I used Task Manager to view the process memory and didn't notice that much memory being taken up by Chrome -- with only one tab for DaniWeb there were 3 processes, the largest consumed about 70Mg. After about 10 minutes the memory had increased by only about 1/2 meg.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

it crashes because the second parameter to itoa() must be a characte array, not just a pointer. See the example here.