nullptr 167 Occasional Poster

Have a look at line 10. What happens when either n or m reference the last vector index?

nullptr 167 Occasional Poster

Yes, the online scanner is free to use. If you have any problems or questions, don't hesitate to post. :)
edit:
Don't install the program recommended in the link you posted. The instructions given at that site won't help for your infection.

nullptr 167 Occasional Poster

Try ESET's online scanner - http://www.eset.com/int/home//products/online-scanner/
or Malwarebytes' Anti-Malware - https://www.malwarebytes.org/ (click on 'free version download')

nullptr 167 Occasional Poster

I also can't get to page 6 of that thread.
Win 7x64 - IE 11, any firefox based browser or via direct download.
Wireshark capture shows:

HTTP  GET /community-center/geeks-lounge/threads/458329/things-i-hate-about-tv-shows/6 HTTP/1.1    
HTTP/1.1 302 Found\r\n ~snip 
Location: http://www.daniweb.com/community-center/geeks-lounge/threads/458329/things-i-hate-about-tv-shows\r\n    
HTTP GET /community-center/geeks-lounge/threads/458329/things-i-hate-about-tv-shows HTTP/1.1
nullptr 167 Occasional Poster

What is the purpose of the following code?

if(!infile)
{
    cout << "" << endl;
}

At line 45: if (names[j].compare(names[smallpos]) < 0); smallpos = j;
this translates to:

if (names[j].compare(names[smallpos]) < 0)
// do nothing
    ;
smallpos = j;

In print_names, you're putting a space between the names when what you want is a new line.

for(int i=0; i<size; i++)
{
    cout << names[i] << " "; // "\n" or '\n' not " "
}

You need to add <string> to your includes.
If you format all your code properly, the errors you're making will be far more easily recognized.

nullptr 167 Occasional Poster
nullptr 167 Occasional Poster

You need to put OSOBA o; in the scope of the while loop and reset the stringstream.

    while(getline(ifsSubor, sRiadok))
    {
        // scope OSOBA instance
        OSOBA o;

        ss << sRiadok;
        ss >> o.meno;
        ss >> o.priezvisko;

        while (ss >> bod) 
        {
            o.body.push_back(bod);

        }
        // reset ss
        ss.str(std::string());
        ss.clear();

        osoby.push_back(o);
    }

In the iteration of the osoby vector, you're not referencing the instance while iterating the vector of doubles.

for (size_t i=0; i<it->body.size(); i++)
            cout << it->body[i] << ", ";
nullptr 167 Occasional Poster

Seeing as your data file contains white space between last and first names, you'd be better off using std::getline for the reading.

void read_names(string names[], ifstream& infile, int& index)
{
    index = 0;
    std::string str;

    while (std::getline(infile, str))
    {
        if (!str.empty())
            names[index++] = str;
    }
}

At line 68: if(names[j].compare(names[i])<0) should be
if (names[j].compare(names[smallpos]) < 0) //or (names[j] < names[smallpos])

The outer loop in selection_sort should be for (int i = 0; i < size-1; i++)
The inner loop for (int j = i + 1; j < size; j++)

Don't forget to close the infile once you've finished reading.

nullptr 167 Occasional Poster

Sample output = garbage given sample input.

It's poorly worded and formatted, but not garbage.
Look across all arrays.
At index 3, all arrays have a value of zero.
At index 4, not all arrays have a value of zero.
Therefore at index 3 the number of sequential zeroes is 1.
Similarly, at index 7 the number of sequential zeroes is 2.
At index 12, seq zeroes = 2

nullptr 167 Occasional Poster

Start out simple and build on your code from there.
Use a for (int i = 0; ...) loop
Check if each array at index i has a value of zero,
if it does then print the index.
Once you've got that part done, you can use a while loop inside the for loop to calculate the number of consecutive zeroes.

It's quite easy to do, so have an honest go at coding it. If you get stuck, post the code and I or one of the many helpful people at this forum will be able to assist. :)

nullptr 167 Occasional Poster

readyQueues[0] is the vector, so you need to specify which element (PCB instance) of the vector you wish to access.
e.g.

printerQueues[0][0].getTau();
printerQueues[0].at(0).getTau();
printerQueues[0].front().getTau();
printerQueues[0].back().getTau();
nullptr 167 Occasional Poster

In the hpp file you have:

#define ROW_LENGTH 4
int correctAnswer[ROW_LENGTH-1]; // correctAnswer[3]
int userSolution[ROW_LENGTH-1];  // userSolution[3]

Meaning that correctAnswer[3] is out of bounds for the array and therefore due to memory alignment has the same address as userSolution[0].

nullptr 167 Occasional Poster

Here's a simple example:

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

class MyClass {
public:
    MyClass(std::string arg = "default") : m_arg(arg) {}
    void display() const {
        std::cout << m_arg << std::endl;
    }

private:
    std::string m_arg;
};

int main()
{
    size_t n = 0;
    // assuming valid input for brevity
    std::cout << "Enter the number of vectors (at least 3): ";
    std::cin >> n;
    std::vector<std::vector<MyClass> > classes_vector(n);

    MyClass mc("This is first");
    MyClass mca("This is also first");
    MyClass mc1("This is second");
    MyClass mc2("This is third");

    classes_vector[0].push_back(mc);
    classes_vector[0].push_back(mca);
    classes_vector[1].push_back(mc1);
    classes_vector[2].push_back(mc2);

    for (auto cl : classes_vector[0])
    {
        cl.display();
    }

    for (auto cl : classes_vector[2])
    {
        cl.display();
    }
    // simple flush
    std::cin.ignore(90, '\n');
    std::cin.get();

    return 0;
}
nullptr 167 Occasional Poster

The above code could be more succinctly written as vector<vector<PCB> > printers(input);

nullptr 167 Occasional Poster

vector<vector<PCB> > printers(3, vector<PCB>()); // 3 vectors

nullptr 167 Occasional Poster

Here's quite a simplistic example of a non high resolution timer that you should easily be able to incorporate in a class, extend its capabilities etc

#include <iostream>
#include <functional>
#include <thread>
#include <chrono>
#include <ctime>

void timer(int msecs, int reps, std::function<void()> callback_func)
{
    for (int i = 0 ; i < reps; ++i)
    {
        std::this_thread::sleep_for(std::chrono::milliseconds(msecs));
        std::thread thread_func(callback_func);
        thread_func.detach();
    }
}

void fire() 
{
    clock_t t = clock();
    std::cout << "fired: " << t << std::endl; 
}

int main()
{
    std::thread my_thread(timer, 3000, 5, fire); // trigger fire() every 3 seconds for 5 repetitions
    my_thread.join();
    std::cout << "\nWe're done!\npress Enter to exit...";

    std::cin.get();

    return 0;
}
nullptr 167 Occasional Poster

At present your code is basically:

if (hun == 3)
{
    // reset variables to zero
}

So, given the above then it can't possibly go beyond 3.
The problem isn't that the code only works when the cout statement is present. Printing to console output just slows the execution of the looping code.
The real problem is that the code you have will never fulfill the requirements for a timer. If you want to create a timer, then you need to rethink the implementation.

nullptr 167 Occasional Poster

Here's a possible implementation of growArray with some printing + comments so that you can see how it works.

#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int* growArray(int* p_values, int& cur_size); 

int main ()
{  
    int next_element = 0;  
    int size = 10;  
    int *p_values = new int[ size ]; 
    int val; 
    cout << "Please enter a number: ";  
    cin >> val;  
    while ( val > 0 )  
    {  
        p_values[next_element++] = val;

        if (size == next_element)  
        {    
            // now all we need to do is implement growArray    
            p_values = growArray(p_values, size);   
        }

        cout << "Please enter a number (or 0 to exit): ";   
        cin >> val;
    } 

    // clean up
    delete[] p_values;

    return 0;
} 

int* growArray(int* p_values, int& cur_size) 
{
    cout << "\ngrowing...\n";
    int *p_new_values = new int[cur_size * 2];

    for ( int i = 0; i < cur_size; ++i )
    { 
        // print the current array content and 
        // copy to new array
        cout << p_values[i] << " ";
        p_new_values[i] = p_values[i];  
    } 
    cout << "\nfinished growing!\n" << endl;
    // update cur_size to the new size
    cur_size *= 2;

    delete[] p_values; 

    return p_new_values; 
}
nullptr 167 Occasional Poster

This should work, I'll leave it to you to play 'spot the difference'

#include <iostream>
#include <string>
#include <ctime>// clock_t, clock, CLOCKS_PER_SEC

unsigned int timer()
{
    return clock();
}


int main()
{
    std::string hello = "Wake up Neo...";
    unsigned int pos = 0;
    unsigned int milli = 0;
    unsigned int hunthou = 0;
    unsigned int tenthou = 0;
    unsigned int thouthou = 0;
    unsigned int hun = 0;

    while (true)
    {  // runs forever atm
        if(timer() > milli)
        {
            milli += 1;
            if(milli == 10)
            {
                milli = 0;
                tenthou += 1;
                if(tenthou == 10)
                {
                    tenthou = 0;
                    hunthou += 1;
                    if(hunthou == 10)
                    {
                        hunthou = 0;
                        thouthou += 1;
                        if(thouthou == 10)
                        {
                            thouthou = 0;
                            hun += 1;
                            if(hun == 10)
                            {
                                hun = 0;
                            }
                        }
                    }
                }
            }

            std::cout << hun << '|' << thouthou << '|' << hunthou << '|' << tenthou << '|' << milli << '\n';
        }

        if (hun == 3)
        {
            std::cout << "\nyes!\npress Enter to continue...";
            std::cin.get();

            milli = 0;
            tenthou = 0;
            hunthou = 0;
            thouthou = 0;
            hun = 0;
        }
    }

    return 0;
}
nullptr 167 Occasional Poster

Post the code that you have, it saves us all from playing guessing games.

nullptr 167 Occasional Poster

At line 63 you have cout << CorpData;
You need to use an instance of CorpData, for example cout << West;

You'll also need to set the precision when you output the data seeing as it contains double precision values. If you add limits to your includes, then the function could be written as:

ostream &operator<<(ostream &lhs, const CorpData &rhs)
{
    lhs << std::setprecision(std::numeric_limits<double>::digits10 + 1)
        << rhs.Name << " "
        << rhs.firstQ << " "
        << rhs.secondQ << " "
        << rhs.thirdQ << " "
        << rhs.fourthQ << " ";

    return lhs;
}
Ancient Dragon commented: good :) +14
nullptr 167 Occasional Poster

how can i validate the Speak() function without re-declare it inside of Cow class?

The only way I can think of is to make the base class Speak() function non-virtual, so that every derived class inherits the same func.

class Animal
{
public:
    void Speak()
    {
        cout << "Generic animal noise!\n";
    }
};


class Cat : public Animal
{

};

class Cow:  public Animal
{

};

//

Cow cow;
cow.speak();
nullptr 167 Occasional Poster

That code looks fine :)

For SelectObject, refer to the MSDN article as to what objects combined with how they are created, need to have their original object value saved and consequently need to be replaced with the original object once the drawing has been completed.
http://msdn.microsoft.com/en-us/library/windows/desktop/dd162957

nullptr 167 Occasional Poster

This may be what you're after.

LPPAINTSTRUCT lpps = new PAINTSTRUCT;
HDC hdc = BeginPaint(hWnd, lpps);
SelectObject(hdc, GetStockObject(DC_BRUSH));
SetDCBrushColor(hdc, RGB(180, 0, 0));
Rectangle(hdc, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom);
//
cambalinho commented: thanks for all +2
nullptr 167 Occasional Poster

Something like this?

hbrBackground = CreateSolidBrush(RGB(241, 245, 251));
//
case WM_PAINT:
{
    LPPAINTSTRUCT lpps = new PAINTSTRUCT;
    HDC hdc = BeginPaint(hWnd, lpps);
    FillRect(hdc, &lpps->rcPaint, hbrBackground);
    // other code
}
cambalinho commented: thanks +0
nullptr 167 Occasional Poster

The code runs fine without any modification!!!

You may think it does, but it certainly doesn't.
Put a cout message before the call to growArray:

if ( size == next_element + 1 )  
{    // now all we need to do is implement growArray
    cout << "\nCalling growArray()\n";        
    p_values = growArray( p_values, size );   
}

You'll find that growArray is never called.
If you increment next_element and growArray is called, you'll strike another problem in that size never changes to reflect the new array size. The growArray function needs to be changed so that it passes a reference (or pointer) to size and in the function the value of size needs to be adjusted.
int* growArray(int* p_values, int& cur_size);

Memory allocated with new[] needs to be released using delete[], not just delete.
int *p_values = new int[size]; should have a corresponding call to delete[] p_values;

nullptr 167 Occasional Poster

Also, 5 is never counted because arr[5] is out of bounds.

sepp2k commented: Seems like I missed the point of the question. +6
nullptr 167 Occasional Poster

What compiler are you using? Are you building it as Win64?

nullptr 167 Occasional Poster

If my friend logic is correct then why I am getting always 0 from random(2), why not getting 1 atleast once out of 37 execution of the code.

You never seed the random number generator with a call to randomize(), therefore you will always get exactly the same result with your calling random(2).

nullptr 167 Occasional Poster

As well as sepp2k's advice, you're coming across one of the common problems associated with declaring using namespace std;
Remove the namespace and change your function to int stringConvertInt(std::string raw) and then there won't be any ambiguity as to which pow function is to be used.

nullptr 167 Occasional Poster

The "file missing" logs are probably the most indicative that you have been seriously hacked, and should NOT be running this system as-is now.

No, the "file missing" entries are indicative of WOW64 redirection. HijackThis is terribly outdated and shouldn't be used on 64 bit systems. For serious malware problems, HijackThis is basically useless regardless of the windows platform.

nullptr 167 Occasional Poster

I honestly lie in bed. :)

nullptr 167 Occasional Poster

If all the drink names are comprised of two words, then it would be far easier to read the file as follows.

    int i = 0;
    string word1, word2;

    while (infile >> word1 >> word2 >> d[i].cost >> d[i].num)
    {
        d[i].name = word1 + " " + word2;
        i++;
    }

You'll also need to fix your payment function. The problem should be obvious once you've correctly read the file and tested.

nullptr 167 Occasional Poster

The code where you read name:

ch = infile.get();
while(true)
{
    if(isdigit(ch) || ch == '\n')
    break;
    else
    word += ch;
    ch = infile.get();
}

textfile looks like this:
Apple Juice 1.50 20

In your code, you read the name as a series of single characters and break when the character is a digit. At that point Apple Juice will be held by the word string, but the 1 in 1.50 will have also been consumed.
If you want to read the file this way, then you'll need to putback the 1 held in ch before you call infile >> d[i].cost >> d[i].num;

nullptr 167 Occasional Poster

At line 42 you have: int largest = a[100]; which is out of bounds for the array.
Set largest to a[0]
At line 45, you're checking the wrong condition, you need to check whether the value is greater: if (a[i] > largest)
Seeing as smallest and largest are (now) initially set as having the value of a[0] you can start the loop iteration from element 1: for (int i = 1; i < 100; i++)

Some food for thought: you could easily combine getting the largest, smallest and total sum inside a single loop.

nullptr 167 Occasional Poster

You need to move the prompt for Numbers (lines 8 and 9) to inside the y loop.
line 14 should be: sum += n;
After that you'll need to flush the input stream.

nullptr 167 Occasional Poster

You need to post the relevant code so that we can see where the actual problem is, not a snippet that works fine.

nullptr 167 Occasional Poster

There's no obvious error in the snippet of code you've posted.
A complete working example based on your code:

#include <iostream>

int main()
{
    using std::cout;
    using std::endl;

    const size_t length = 26;

    const char alphabet[length] = {
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
        'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
    };

    char Caesar[length] = {0};

    int shift = 4;

    cout << "Original Alphabet:  ";
    for(int i = 0; i < length; i++)
        cout << alphabet[i];
    cout << endl;

    cout << "Shift Value: " << shift << endl;

    cout << "Encrypted Alphabet: ";
    for(int i = 0; i < length; i++)
    {
        Caesar[i] = alphabet[(i + shift) % length];
        cout << Caesar[i];
    }

    std::cin.get();

    return 0;
}

/* 
Original Alphabet:  ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift Value: 4
Encrypted Alphabet: EFGHIJKLMNOPQRSTUVWXYZABCD
*/
nullptr 167 Occasional Poster
typedef char alphabet[26];

alphabet alpha = {
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 
        'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
};

What you could do is iterate through the text that you read in and use a rotate function on each character:

char rotate_char(char ch, int shift)
{
    if (!isalpha(ch))
        return ch;

    // (tolower(ch) - alpha[0]) gives the index into the array
    // modulus sizeof(alpha) ensures that the shifted index is in the array range

    return alpha[((tolower(ch) - alpha[0]) + shift) % sizeof(alpha)];
}
nullptr 167 Occasional Poster

line 18: int Main() should be int main() - note case sensitivity.
Also you never call your rollDice function, so you'll never know the roll count.
line 29: does nothing, seeing as you are not getting input for y from the console.

Can you work out how and where to call your rollDice function?

nullptr 167 Occasional Poster

One of my dogs had an ear infection and the odour was exactly as you've described. The only treatment was with antibiotics. These infections can cause a dog an awful lot of pain if left untreated, so I'd recommend taking him to the vet ASAP. Your nose and the dog will be grateful, though your wallet may feel a lot lighter.

nullptr 167 Occasional Poster

For sources, just google for linux ntfs source code, or look at the source for any linux distro.

nullptr 167 Occasional Poster

I'm about to go to bed, so I've not commented much of the code.
You also need to write a function to free the memory used by each node.
Here's your code, with the global variables moved to inside main()

#include <iostream>
//#include <conio.h>
//#include <algorithm>

//for brevity only
using namespace std;

struct BST {
    int value;
    BST* left;
    BST* right;
};

int search_bst(BST* node, int key){
    if (node == NULL)
        return -1;
    if (key<node->value)
        return search_bst(node->left,key);
    if (key>node->value)
        return search_bst(node->right,key);
    else
        return node->value;

}

void insert_bst(BST* &treeNode, BST* newNode){
    if(treeNode == NULL)
    {
        treeNode = newNode;
        return;
    }
    if (newNode->value<treeNode->value)
        insert_bst(treeNode->left, newNode);
    else
        insert_bst(treeNode->right, newNode);

}

void inorder_bst(BST* tree){
    if (tree==NULL)
        return;
    inorder_bst(tree->left);
    cout<<tree->value<<" ";
    inorder_bst(tree->right);
}

void binary_tree_sort(BST* &btree, int* a, int length){
    BST* item;
    for(int i=0; i<length; i++){
        item=new BST();
        item->value=a[i];
        item->left = item->right = NULL;
        insert_bst(btree, item);
    }
    inorder_bst(btree);
}

int main()
{
    int a[] = {1, 5, 7, 4, 9, 8};
    int size = sizeof(a) / sizeof(a[0]);
    BST* binary_search_tree = NULL;

    binary_tree_sort(binary_search_tree, a, size);

    cout << endl;

    int ret = search_bst(binary_search_tree, 7); //  return 7
    cout << ret << "\n";
    ret = search_bst(binary_search_tree, 11); // not found return -1
    cout << ret << endl;

    cin.get();

    return 0;
}
nullptr 167 Occasional Poster

Do you have a question regarding any difficulties?

nullptr 167 Occasional Poster

See if you can get a hold of the Windows 8 "Use now and serve me a subpoena later" edition.

nullptr 167 Occasional Poster

Thank you gerbil for providing Lynn with that information.

I go on to these sites, get more viruses and no explanation. nice.

I was called away on a large malware removal and data recovery job, so I've not been able to respond. None of those sites that I linked to serve any type of malware. It's possible that the malware you have, is downloading more malware to your system, or redirecting you to malicious sites that host exploit kits.

TDSSKiller is an application provided by Kaspersky Labs. that detects and removes many types of rootkits.
Rootkit definition as provided by Kaspersky:

A rootkit for Windows systems is a program that penetrates into the system and intercepts the system functions (Windows API). It can effectively hide its presence by intercepting and modifying low-level API functions. Moreover it can hide the presence of particular processes, folders, files and registry keys. Some rootkits install its own drivers and services in the system (they also remain “invisible”).

Whether you decide to run these programs is your choice. If you don't feel comfortable in doing so, then I'd suggest disconnecting your computer from the internet and take it to a reputable PC repair service.

nullptr 167 Occasional Poster

Rogue Killer is only showing two false positives.

Download TDSSKiller and run it. Once it has started, click on 'Change parameters', leave the default settings for 'Object to scan' and put a check mark in both Additional options. Press OK, then Start scan.
If it detects anything, change the action to 'skip', press continue and exit the program.
A log will be created at the drive root, usually C:\TDSSKiller.*_log.txt. Post the log.

Also follow the instructions in my previous post for running OTL.

nullptr 167 Occasional Poster

Both links give me a 404 page not found. Just paste the Rogue Killer log into a reply.
Download OTL. Just double click to run. In its settings, toggle Output to Minimal Output, then press 'Run Scan'. When it has finished there should be 2 log files. Zip the logs and attach.

nullptr 167 Occasional Poster

AC23 does equal -21469 when the size of an integer is only 16 bits. Any value from 0x8000 to 0xFFFF will have its most significant bit set, meaning it will have a negative value.

To accept larger input for the other conversions, you would need to get the input as a string and validate what has been entered. For example, in the Binary2Decimal function, the only valid input is 0s and 1s.
Here's an example of the binary conversion using the above.

void Binary2Decimal()
{
    char buffer[17];
    int len, i, total = 0, value;

    printf("[BINARY TO DECIMAL CONVERSION]\n\n");
    printf("Enter a Binary number: ");
    // accept a maximum of 16 chars
    scanf("%16s", buffer);
    printf("\n");

    len = strlen(buffer);

    // convert and check if we have valid data
    for (i = 0; i < len; ++i)
    {
        value = buffer[i] - '0';
        if (value != 0 && value != 1)
        {
            printf("Invalid binary data\n");
            return;
        }
        total = (total << 1) | value;   // (total * 2) + value
    }
    printf("Decimal equivalent is: %d\n", total);
}
nullptr 167 Occasional Poster

What operating system are you running and is it 32 or 64 bit? What anti-virus is installed?

To get started, download and install Malwarebytes Anti-Malware, let it update the database, then run a Quick Scan. Allow it to quarantine anything detected and reboot to complete disinfection.
Attach the log file to your post.

Download the appropriate version of Rogue Killer for your OS.
Rogue Killer 32 bit - http://www.adlice.com/softs/roguekiller/RogueKiller.exe
Rogue Killer 64 bit - http://www.adlice.com/softs/roguekiller/RogueKillerX64.exe

It doesn't need installation, so just double click to run. After it completes its pre-scan, accept the licence agreement, then click on Scan. When it has finished running, just exit the program, don't have it fix anything at this point. A log will be created on your desktop. Attach the log to your post.

If you have any problems or questions just let me know.