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

The only time I've seen it make any real difference is when the class object is a reference, in that case you have to initialize it the way you showed.

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

Do I need a header file and a .cpp file both to use a custom defined class?

Depends on the how complex the class is. In the simplest case the class and implementation can both be in the header file. I like to use inline for very short methods. For example you can put all this in a header file.

class Foo
{
public:
   Foo() { _x = 0; } // inline method
   void setX(int x) {_x = x;} // another inline method
   int getX() {return _x;} // another inline function
private:
   int _x;
};

Template classes and their implementation code almost always has to be in a header file, implementation can't be compiled separately in *.cpp file(s) because the compiler doesn't know the data type at that time.

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

Is that supposed to be written in java or c++? There is a java form for such questions.

In either event, no one here will do your homework for you. Post the code you have written and ask questions about what you don't understand. It is YOUR responsibility to do this program, not ours.

Of course, I'll be glad to write it for you after you deposit $10,000.00 USD in my personal PayPal account :)

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

The only program I miss from XP is the original version of Diablo RPG. There are several MS-DOS games I liked. Otherwise, I don't miss a thing from XP.

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

objects can't be declared in case statements without { and }, for example:

switch(choice)
            {
            case 1:
            {
                ifstream levelOne;
                    levelOne.open("level1.txt");
            }
            break;

That also means that the stream will be closed as soon as the break statement is executed and the switch is exited. I think you need to rethink what you are doing here and devise a different solution. You would just declare one fstream object before the switch then use it to open the correct file

ifstream in;
switch(choice)
            {
            case 1:
                    in.open("level1.txt");
                    break;
            case 2: 
                    in.open("level2.txt");
                    break;
            case 3: 
                    in.open("level3.txt");
                    break;
            case 4: 
                    in.open("level4.txt");
                    break;
            case 5: 
                    in.open("level5.txt");
                    break;
            default:    cout << "Invalid option please try again" << endl;//when an incorrect option 
JasonHippy commented: I was just about to suggest the same thing! You beat me to it! :) +9
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To be similar to argv in main argument you need to allocate one more than count pointers, the last pointer is NULL. That will also let you pass argv to other functions without needing to also pass the number of strings it contains.

Next, argv needs to have it's own copy of all strings so that the pointers do not get invalidated when the origianal strings are destroyed.

You also need to rename the function because it conflicts with argv array name.

#include <stdarg.h>
char **makeArgv(int count, ...)
{
    va_list args;
    int i;
    char **argv = malloc((count+1) * sizeof(char*));
    char *temp;
    va_start(args, count);
    for (i = 0; i < count; i++) {
        temp = va_arg(args, char*);
        argv[i] = malloc(sizeof(temp+1));
        strcpy(argv[i],temp);
    }
    argv[i] = NULL;
    va_end(args);
    return argv;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 66 is wrong. Check it with my previous post.

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

The problem appears to be in this function

ListNode *LinkedList::insert(ListNode *item, ListNode *sortedList)

That function is destroying the original list. It should be inserting item into SortedList and returning SortedList. Instead, it is doing just the opposite.

One way to solve the problem is for insert() to create a new node and add to sortedList, leaving item list link intact.

ListNode *LinkedList::insert(ListNode *item, ListNode *sortedList)
{
    // If sortedList is empty or first member of the  sorted list
    // is greater or equal to item then item becomes the first
    // member of the augmented list

    if (sortedList == NULL || sortedList->value >= item->value)
    {
        //item->next = sortedList;
        return new ListNode(item->value, sortedList);
    }

    // Use recursion to insert the item at the right place in the tail
    sortedList->next = insert(item, sortedList->next);
    return sortedList;
}

You also have to change this function so that it can iterate through the entire original linked list. The problem is that the last line will cause a memory leak, so before changing head = SortedList you have to delete the linked list pointed to by head.

void LinkedList::sort()
{
    ListNode *sortedList = NULL;

    //
    // USE A while LOOP TO CONTINUE LOOPING
    // AS LONG AS HEAD IS NOT EQUAL TO NULL
    ListNode *item = head;
    while (item != NULL)
    {
        //
        // TO MOVE POINTER TO NEXT
        sortedList = insert(item, sortedList);
        item = item->next;
    }
    head = sortedList;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

And with a pair of unsterilised cissors even, recipe for serious infections.

I'd wipe then off on my muddy cow-shit ridden cloths first :)

I was actully just joking when I made that remark, then someone pointed out it was a serious option.

Stuugie commented: lmfao, does nobody here see this humour? +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't compile each module down to *.exe, but instead just to object module then use the linker to link both object modules together at the same time. And you should be creating a console project, not a Windows project. The error you posted indicates you created the wrong kind of project.

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

Move the include statement down below to line 4, after the ifdef statement. Yes, you can put include statements in header files, it's done all the time.

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

I don't think some of that came out right -- what is �$� ?

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

sorry sir,for mistakes i have made

Take 10 lashes with a wet noodle :)

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

Why do you need to do that? Just have an array of max possible size, then have a variable, such as arrsz, that contains the size you want (either SIZE_10 or SIZE_20). It won't matter if you have extra elements in the array that aren't used.

extern unsigned char marray[arrsz];

You can't declare an array until you know how big it is. The value of arrsz has to be known before that array can be declared, and using a c++11 compliant compiler. extern assumed a global variable, so that won't work.

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

He meant i < j in the above post

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

They are all really chars.

There really is no such thing as a char in C and C++ languages, the data type char is just a one-byte integer with a range of values from 0 to 255 (unsigned) or -127 to 127 (signed). The compiler treats 'A' as an integer, not as a character.

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

That's a new feature of c++11 iso standards. Some compilers such as Visual Studio have not implemented it yet, while others such as g++ may need special flags.

For compiles that don't support that, just change line 81 to this:

string* boardWithPieces = new string[rowLength*columnLenght];

As for the freezing problem -- look at line 75 and see if you can figure out what's wrong with it (Note: very common error)

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

delete line 26 because it destroyed the seed generated by line 25.

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

I would do it by using an array of 255 ints, each element in the array represents one of the characters in standard ascii character set. So, if you enter 'A', then all you have to do is increment array['A']++. When done, all the non-zero elements are what you want. Now, you know that many of the 255 elements will be unused, so you can limit the array to only 126 or fewer. If the array has 126 elements (values above 126 can not be entered on the standard English keyboard).

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

Mother Hubbard from Mother Goose was originally written in about 1590 and Mother Goose's Melody was first published sometime in the 1760s.

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

Is it possible that I could get it back?

Probably not -- you auto lose the badge when the period of your donation expires. For example if you donate $3 for one month and don't renew it the badge will only appear for the month of the donation. It's not permanent.

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

The difference is that eof() doesn't recognize end-of-file until an actual read is performed. When at end-of-file line 31 doesn't know it yet until line 33 is executed. But line 34 is executed whether at eof or not. That's a common mistake that new programmers do -- IMO eof() is almost a useless function.

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

line 5: how does that variable ever get reset back to 0 so that you can call the function again for a different string?

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

There are two kinds of strings -- standard strings are char* which are 1 byte per character. This is normal in English language and a few other languages too. The other kind of strings are UNICODE strings, or wchar_t*, where each character is represented in two or more bytes. All languages, that I know of, can be represented in UNICODE characters.

Look at line 15 of the code you posted. LPCTSTR is a Microsoft typecast for const char*. Now in line 33 you declare a pointer of type TCHAR, which is another Microsoft macro (tchar.h) that can be either char* or wchar_t* depending on whether you compile the program for UNICODE or not. line 50 calls the function wcscpy() which is UNICODE only function that is the same as strcpy() but takes two wchar_t* parameters instead of two char* parameters.

In otherwids, you code is mixing two very different character types, char* and wchar_t*. Both client and server must speak the same language (use the same character representation). What I would do if I were you would be change OnClickedBsend() to use UNICODE strings just like OnReceive().

Here is a much more complete explanation

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

That's because g points to an entire class and you need a friend class that prints all of it. cout has no idea how to display the class.

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

iterators are pointers and need the -> operator not the dot operator

            cout << left << setw(0) << "--d" << diskQueue.size() << left << setw(4) << " "
                << left << setw(14) << g->getFilename() << left << setw(14) << g->getMemoryStart()
                << left << setw(14) << g->getFileLength() << g->getRW() << endl;
smitsky commented: Excellent help! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Remove const keyword after PCB::screen. const functions can't use the iterator.

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

Remove const keyword after PCB::screen.

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

According to this artcle origins of the word OK is unknown, but speculation suggests it came from the 1840 American presidential election.

The oldest written references result from its use as a slogan by the Democratic party during the American Presidential election of 1840. Their candidate, President Martin Van Buren, was nicknamed 'Old Kinderhook' (after his birthplace in New York State), and his supporters formed the 'OK Club'.

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

Why don't you just bind the DataGridView with the sql?

اشرف_1 commented: I do not understand +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 7: why are you repeating the same character 22 times in currentLine? Isn't once enough?

int j = 0;
while ((c = fgetc(file1)) != EOF) {
     currentLine[j++]= (char)c;
currentLine[j] = 0;

line 10: you need to NULL terminate currentLine before calling sprintf().

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

// t-1 = second last and t-2 = secound first

What?? The second last is t-2, the second first is 1. Why do you need loops to find the second last and second first numbers?

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

If you wrote that code then you should know what command-line arguments it needs. Looks like it takes 11 integers on the command line.

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

No. array a is a one-dimensional array so a[i][j] won't work.

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

line 5 is undefined behavor, the value printed for i may be difference from one compiler to the next.

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

multi-statement for loops and if statements require { and } around them

for(i = 0; i < 10; i++)
{
   // blabla
}

line 23: y < y will never ever be true. Probably should be y < 10

Brittany_1 commented: I can't believe I overlooked the curly Qs. Changing line 23 helped also. Now the only problem I'm having is that when it asks for input for the test scores, it's only asking for the last person's name entered. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What have you done so far? Do you know how to read a file? If not, then you need to read tutorials on ifstream (input file stream) and ofstream (output file stream).

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

line 3 is incorrect because it is indexing beyond the bounds of the array. You should initialize highest as the first item in the table

int highest = table1[rows][0];

The second problem with that function is line 4. It should be i < COLS

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

Probably depends on what compiler you are using. Here's the output from VC++ 2013

1   1
2   3
3   9
4   33
5   153
6   873
7   5913
8   46233
9   409113
10   4037913
11   43954713
12   522956313
13   2455009817
14   3733955097
15   5738265113
Press any key to continue . . .
newbiewwcode commented: Thanks for helping. I got it to work. when it does the addition, long long got demoted to an int type. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The first parameter should be identical to that of all the other functions.

array[][COLS]

Otherwise that function looks ok. To call it from main() you will have to prompt for the row number, then call the function with the desired row number. Same for column number.

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

Did you look up their descriptions on MSDN?

Win32_DiskDrive
Win32_LogicalDisk
Win32_Volume
Win32_DiskPartition

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

The file probably has a '\n' after the last character. Edit the ffile to remove the last '\n'

variable c should be declared as int, not char, because fgets() returns an int.

int c;

line 17: It is not necessary to do that, just print like this:

printf("%d %c\n",c,c);

2teez commented: nice one bro! Fastest fingers... +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your two links are broken.

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

C presumes malloc returns int and silently casts your 64 bit pointer to a 32 bit integer.

Just because the program is running on a 64-bit operating system doesn't mean malloc() will return a 64-bit pointer. It depends on the compiler, not the operating system. And if the compiler is set to produce 64-bit code it will also produce 64-bit integers.

[edit]Just to prove myself wrong, I tested by compiling a simple program. The size of int is the same for both 32 and 64 bit programs. Oh well, so much for my theory :)

int main()
{
    cout << "sizeof(int) = " << sizeof(int) << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

We are supposed to help you help yourself. What problems or compiler errors are you getting with the code you posted? Post the error message(s) and the line numbers on which they occur. Afterall, we can't see your computer monitor.

You started with probably the most difficult question, try doing the 1st one first.

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

Hint: The first question, about converting from text 'A' to ascii 65

Every character you can type from the keyboard has a numeric value. See this standard ascii table.. In C and C++ you don't have to do anything at all special in order to convert from 'A' to 65 because the two are the same thing.

char c = 'A';
cout << c << " the ascii value is: " << (int)c << '\n';

It's nothing more than typcasting the char to an int.

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

move lines 14-23 into a method, you can't have executable code outside functions.

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

use strcpy() to copy the tempFile to name. strcpy(fileName[numberFile].name,tempFile);

joel.alva.18 commented: Thanks :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Because Oct 31 = Dec 25

I don't get it.

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

Displaying the ascii value is simple -- just typecast it from int to char.