pseudorandom21 166 Practically a Posting Shark

My simple POP3 client (set up for Gmail) isn't downloading all of my messages...
Any idea why?

I have 350 messages in my inbox and the program only says 296 of them show up.

Program.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Net.Security;
using System.IO;
using System.Data;

namespace POP3Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            PopGmail mail = new PopGmail();
            Console.Write("Email: ");
            string email = Console.ReadLine();
            Console.Write("Password: ");
            string password = Console.ReadLine();

            Console.WriteLine("Connecting.");
            if (!mail.Connect("pop.gmail.com", 995))
            {
                Console.WriteLine("Connect failed, attempted connection to pop.gmail.com on port 995 (client).");
                return;
            }
            Console.WriteLine("Connected.");
            if (!mail.Login(email, password))
            {
                Console.WriteLine("Login failed, valid username/pass? POP3 enabled on gmail settings?");
                return;
            }

            int messageCount = mail.GetMailCount();
            Console.WriteLine("Number of email messages reported: " + messageCount.ToString());

            //for(int i = 1; i <= messageCount; i++)
            //{
            //    byte[] bt = Encoding.ASCII.GetBytes(mail.GetMessage(i));
            //    FileStream fs = new FileStream("Emails\\" + i.ToString() + ".txt", System.IO.FileMode.Create);
            //    fs.Write(bt, 0, bt.Length);
            //    fs.Close();
            //}

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
            mail.Disconnect();
        }
    }
}

and more importantly,
POPGmail.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Security;
using System.Net.Sockets;
using System.Web;
using System.Windows.Forms;

namespace POP3Sharp
{
    class PopGmail
    {
        TcpClient m_tcpClient = new TcpClient();
        SslStream m_sslStream;
        int m_mailCount;
        byte[] m_buffer = new byte[8172];

        public PopGmail()
        {
            m_mailCount = -1;
        }

        /// <summary>
        /// Connect to pop3 server "host" using "port" and auth SSL as client.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        public bool Connect(string host, int …
evry1falls commented: Very helpful, i'm using it to develop a vb.net app. +0
pseudorandom21 166 Practically a Posting Shark

Most of the features you want are probably available via the operating system API, I'll assume you're using Windows so here's the API ref.

http://msdn.microsoft.com/en-us/library/ff818516(v=vs.85).aspx

of course you don't have to roll your own, there is plenty of code available for random stuff.
http://www.codeproject.com/KB/cpp/AddColorConsole.aspx

otherwise here's the console link:
http://msdn.microsoft.com/en-us/library/ms682087(v=VS.85).aspx

That codeproject lib looks like a good one because it implements changing text colors as some stream manipulators.

Agouri commented: Helpful links in my C++ help thread +0
pseudorandom21 166 Practically a Posting Shark

Yes you can:

1)
Write the "move" function so that it operates properly using the "WARRIOR" information.
ex:

const std::string WARRIOR = "Warrior";

class Character
{
public:
std::string Type;
void move()
{
   if(this->Type == WARRIOR)
     ;//move
}
};

2)
Redesign using polymorphism with a base class and a Warrior derived from it.
ex:

class CharacterBase
{
public:
virtual void move() = 0;//Pure virtual
};

class Warrior : public CharacterBase
{
public:
virtual void move()
{
   //Move your warrior.
}
};

void MoveCharacter(CharacterBase *myChar)
{
   myChar->move();
}

int main()
{
  Warrior myKnight;
  MoveCharacter(&myKnight);
}

3)
Use a function pointer or functor.
ex)

typedef void (*MoveFunc)(void);// named type for my func. pointer

void MoveWarrior()
{
   //etc.
}

class Warrior //redundant, etc.
{
  MoveFunc moveFunction;
  public:
    void move()
    {
      moveFunction = MoveWarrior;
      moveFunction();
    }
};

Please excuse minor bugs.
Also, there are a large number of other strange things you can do with C++ so you're pretty well-off on finding a way to do it.

pseudorandom21 166 Practically a Posting Shark

There are tons of specialization areas for programmers, you could look into artificial intelligence, or automation to name a couple.

I don't feel this list is complete,
http://www.bibl.u-szeged.hu/afik/compw.html

pseudorandom21 166 Practically a Posting Shark

I don't know how 7zip makes those.
Visual Studio does provide a type of installer project though.

XOR encryption:
http://en.wikipedia.org/wiki/XOR_cipher

Zssffssz commented: Try's his hardest. +2
pseudorandom21 166 Practically a Posting Shark

"std" is a namespace and it is short for "standard".

If you don't include "using namespace std;" then you have to do this:

#include <iostream>
int main(){
std::cout << "Notice the namespace followed by the scope resolution operator?" << std::endl;
}
pseudorandom21 166 Practically a Posting Shark

Here's my feeble attempt:

#define _WIN32_WINNT 0x0601
#include <windows.h> 
// when you use Windows.h it should be the first header
// you include, because windows.h is really quite picky and lame about that sort
// of thing.
#include <iostream>

void DoFullscreen(HANDLE hOutput)
{
	BOOL result = SetConsoleDisplayMode(hOutput, CONSOLE_FULLSCREEN_MODE, NULL);
	if( !result )
		std::cerr << "Last error: " << GetLastError() << std::endl;
}

int main()
{
	std::cout << "Running test one.. " << endl;
	// One of these structures.
	CONSOLE_SCREEN_BUFFER_INFOEX bufferInfo = {0};
	bufferInfo.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
	// Get a handle to the console window.
        HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	if(hOutput == INVALID_HANDLE_VALUE)
		std::cerr << "GetStdHandle() -> " << GetLastError() << std::endl;
	// Fill bufferInfo with the window information, using the window handle.
	if(!GetConsoleScreenBufferInfoEx(hOutput, &bufferInfo))
		std::cerr << "GetConsoleScreenBufferInfo() -> " << GetLastError() << std::endl;
	// If full-screen mode is supported (it's not on W7 and Vista)
	if(bufferInfo.bFullscreenSupported)
	{
		std::cout << "Good news, your system supports full-screen!" << std::endl;
		DoFullscreen(hOutput);
	}
	// Set current size to maximum.
	else
	{
		bufferInfo.dwSize = bufferInfo.dwMaximumWindowSize;
		// Set the new console screen buffer info structure.
		if(!SetConsoleScreenBufferInfoEx(hOutput, &bufferInfo))
			std::cerr << "SetConsoleScreenBufferInfo() -> " << GetLastError() << std::endl;
	}
        std::cout << "Press ENTER to continue..." << std::endl;
        std::cin.get();
	std::cout << "Running test two.. " << endl;
	HWND hConsoleWindow = GetConsoleWindow();
	if(hConsoleWindow == NULL)
		std::cerr << "GetConsoleWindow() -> " << GetLastError() << std::endl;
	ShowWindow(hConsoleWindow,SW_MAXIMIZE);
	std::cout << "Press ENTER to continue..." << std::endl;
        std::cin.get();
	return ERROR_SUCCESS;
}
pseudorandom21 166 Practically a Posting Shark

OR you can just always thread.
On Linux you can use fork().
On windows call CreateThread(), something like this:

#include <windows.h>
#include <iostream>

DWORD CALLBACK threadFunc(void*)
{
printf("New Thread");
 return 0;
}

int main(int argc, const char* argv[])
{
  DWORD id;
  HANDLE h = CreateThread(NULL, 0, threadFunc, NULL, 0, &id);
  int d;
std::cin >> d; //wait for user to input before terminating
 return 0;
}

WARNING: The code is C++, so you will have to change it a bit for C.

It's also important to note that Visual Studio has their own version of CreateThread and using CreateThread with VS leaks memory. For some reason <shrug>.

Anyway, for Visual Studio users you can use _beginthreadex() and _endthreadex(),
http://msdn.microsoft.com/en-us/library/kdzttdcb(v=VS.100).aspx

sergent commented: .. +5
pseudorandom21 166 Practically a Posting Shark

It's called an imagination, in my country those who don't have one shouldn't be writing a thesis.

Salem commented: Damn straight! +0
pseudorandom21 166 Practically a Posting Shark

I was referring to the algorithm. Tweaking the parameters (slope_max, slope_change and line_length) can
produce interesting results. Making slope_change and line_length variable can also yield very interesting results.


There's nothing wrong with hacky multi-line macros. On the contrary, they make my code more boost-like :D

Noo! That's what inline functions are for..

pseudorandom21 166 Practically a Posting Shark

I'm no licensing expert but I do know that I hate the GPL, what if someone wants to use a part of your code in a product, or something that you don't want to give the source away? What if *you* want to use a part of it in something you don't want to give the source away? The GPL is just a license saying "you can't sell this and you have to give source code if you use it".

F' the GPL and the "Open Source Initiative" free the code!

The way I see it the GPL is imposing restrictions on the finished product and I don't think that's a good thing. I, understandably as a developer, want free source code instead of free software.

jwenting commented: well said +0
pseudorandom21 166 Practically a Posting Shark

lool, so what was the idea? You wrote a program and you don't know what it does?

What exactly is done to the input to make the output?

pseudorandom21 166 Practically a Posting Shark

Not a chance. At least the VTOL is unmanned :)

pseudorandom21 166 Practically a Posting Shark

line 7, forgot a :

pseudorandom21 166 Practically a Posting Shark

My guess is that there is an event that is raised every time the text changes, find that event and add the proper handler. In your handler I'm guessing you'll need to use the EventArgs (or similar) information to determine if the space was entered.

Really, my guess is that you can google this pretty easily when you're looking through the events to find the one you want.

After a google search I hath found keydown, keypress, and keyup events for that control.

Those will definitely work just fine.

Also, I just tested this and it works.

dotancohen commented: Thank you very much! +2
pseudorandom21 166 Practically a Posting Shark

I like programs that support command line arguments. There, there's my opinion, now I'll just brace for the backlash.....

Narue commented: Me too. :) Console filters aren't common anymore, but they're super useful. +17
pseudorandom21 166 Practically a Posting Shark

Maybe if the pointer to the base of the array is NULL, then it's not an array at all. But it could be, and it's definitely empty.

Ancient Dragon commented: good point :) +17
pseudorandom21 166 Practically a Posting Shark

Isn't it called the "Order of Operations" ? Or rather, in a programming language, operator precedence.

pseudorandom21 166 Practically a Posting Shark

Your teacher expects you to copy and paste the code on cboard.cprogramming.com and have us explain it to you? I think a monkey just flew right out... nevermind.


You know I always had a problem with copying & pasting code, I still do. I never did it, I typed it myself even when it's free to anyone to use for anything. I just didn't do it, maybe you don't have what it takes? You know, that "ethics" thing?

Somehow stealing the idea and providing your own implementation may help, idk. I hate to call it stealing but I feel that way, even when it's free to anyone.

What have you accomplished by copying and pasting? In my opinion there is further benefit to writing it yourself.

Salem commented: Nicely put +17
pseudorandom21 166 Practically a Posting Shark

Hello all, a lot of times I see C# code written without the use of #region and #endregion, I'm just wondering if there is any reason not to use it, and what are your thoughts on using it.

I think it's an amazing feature that lets you clearly identify groups of functions/classes with similar functionality.

i.e.,

#region PROGRAM_INIT
//Functions to initialize variables, etc.
#endregion

#region STRUCTION
//ctor
//dtor
#endregion

#region EVENTS
//Program events go here.
#endregion
ddanbe commented: Good question. +14
pseudorandom21 166 Practically a Posting Shark

:D

I've seen a lot of ghetto, when they get money they spend it on drugs. Not to say this is true of everyone in every ghetto, but I would say the likelihood of such a thing being widespread is quite a concern for someone feeling righteous. There is trash living in America the likes of which you may not believe.

Osama is dead, so can't we move on to other criminals?

pseudorandom21 166 Practically a Posting Shark

probably want to include windows.h before any other includes.

pseudorandom21 166 Practically a Posting Shark

Once you drag + drop a "control" on your "form" you can select the control and in the properties pane at the top there is an "events" button you will want to click.

Those events are most likely relevant to using your logic with your GUI. Find one, such as the "MouseClick" event, double click the white part of the drop-down to have the editor generate one for you.

pseudorandom21 166 Practically a Posting Shark

using .NET means making your native C++ project a Mixed Mode assembly that contains both native machine instructions and MSIL. If you have compilation trouble using a mixed mode then you may want to look into using the #pragma managed and #pragma unmanaged.

As far as using it to make a GUI for your C++ project, click on your project name in the solution explorer & select add-> new item : Windows Form.

You can also use QT (which is not free) wxWidgets (I think it's free), MFC, or just native Win32 API calls.

For MFC you may have a little difficulty unless you take a lot of time trying to understand Microsoft's framework and then how to use it for your applications.

If you don't mind distributing your application with a couple of DLLs you can use QT (afaik). You don't have to distribute your source under the LGPL (as far as I know, and I'm NOT a lawyer so don't quote me on this).

QT is very nice IMO.

pseudorandom21 166 Practically a Posting Shark

The Windows API has SendInput, and you need to send the hardware scan code of the key you wish to press for games to detect it (I know this from experience).

I have a small example in C++ here, I'm assuming you can Pinvoke it with no trouble.

#include "stdafx.h"
#pragma comment(lib,"user32")
using namespace std;

int main()
{
	char ch = 'a';
	INPUT key;
	memset(&key,0,sizeof(INPUT));//Zero the structure.
	key.type = INPUT_KEYBOARD;
	key.ki.dwExtraInfo = GetMessageExtraInfo();//<-- you will need to pinvoke this too.
	key.ki.wScan = 
		static_cast<WORD>(MapVirtualKeyEx(VkKeyScanA(ch), MAPVK_VK_TO_VSC, GetKeyboardLayout(0)));//more pinvoking
	key.ki.dwFlags = KEYEVENTF_SCANCODE;//<-- you will probably have to declare this constant somewhere-
	//in your C# program.

	//Ready to send the key-down event.
	SendInput(1, &key, sizeof(INPUT));
	
	Sleep(1000);//Wait one second before sending key-up.

	//Sending key-up.
	key.ki.dwExtraInfo = GetMessageExtraInfo();
	key.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;//Key-up need be defined too, or just use the value.
	SendInput(1, &key, sizeof(INPUT));
}

http://www.pinvoke.net/default.aspx/user32/sendinput.html

http://msdn.microsoft.com/en-us/library/ms646310(v=vs.85).aspx

Overall it seems very tedious to use the raw Winapi w/ C# to do this, there may be a better way that I am not aware of.

It appears as though SendKeys offers the familiar C# level of abstraction, please see here: http://msdn.microsoft.com/en-us/library/ms171548.aspx

--edit--
Actually it sounds as if a windows low-level keyboard hook would be better for your purpose, you can intercept the input before it reaches the application and either prevent it from reaching it or modify it whilst simulating input in response.

There appears to be a C# wrapper hosted on …

pseudorandom21 166 Practically a Posting Shark

http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/

http://www2.research.att.com/~bs/bs_faq2.html#int-to-string

In C++, stringstreams are amazing.

template<class int_type>
int_type stoi(const char *str){
  int_type i = 0;
  std::stringstream(str) >> i;
  return i;
}
//You get the idea.
pseudorandom21 166 Practically a Posting Shark

I added a #pragma managed before the form's definition and it works fine now. <shrug> the clr settings are correct.

pseudorandom21 166 Practically a Posting Shark

I see this all the time, and I hope by me explaining it, will make it clear to you.

After creating an array like so: char buffer[10] = { 'a','b','c'}; when you use the operator[] ( [ # ] ) you are accessing a SINGLE ELEMENT. No matter how you try to twist the meaning of using the operator[] on a simple array, it always does the same thing.

This is accessing a SINGLE element of the array, and if I did this: std::cout << buffer[1]; it would access the second element of the array, the second character. It would print 'b'.

The operator[] is NOT magic.

Pointers may seem like magic, but they aren't either. In fact, when I learned to program and had the epiphany that nothing about the computer is magic I was also disappointed.

A C style string (sometimes called a C string) is an array of char's with the last character set to 0, or NULL, or '\0'. The program will process characters in a C string until the terminating NULL character is encountered, this avoids needing to specify the length/size of a string. Thus an algorithm can simply process characters until the character NULL is encountered. This is very important for large strings. Variable length strings are used. The string can occupy a part of, or all of (minus the NULL) a character array.

Pascal strings were limited by a value specifying the length, please see this wikipedia …

pseudorandom21 166 Practically a Posting Shark

There is a "for each" in C++/CLI. In C++ we do have a function named that: http://www.cplusplus.com/reference/algorithm/for_each/

pseudorandom21 166 Practically a Posting Shark

If you are using Windows it's pretty simple, but not exactly guaranteed to not "flash" a console window for a moment.

What sfuo meant is you can tell your compiler to not spawn the console window. It's a compiler switch.

Now, this is the "dirty" way...

#include <Windows.h>

int main()
{
	HWND windowHandle = GetConsoleWindow();
	ShowWindow(windowHandle,SW_HIDE);
}
pseudorandom21 166 Practically a Posting Shark

I hate to spring this kind of things on you, but if you expect some Americans to look at your code (which I am a native speaker of), you may want to read/write it like us too.

pseudorandom21 166 Practically a Posting Shark

I don't think there is a standard way to do this (if I'm wrong I would like to know) so you will probably have to rely on the operating system. If you're using Windows/Linux the exact functions will vary.

Windows:
http://msdn.microsoft.com/en-us/library/078sfkak(v=vs.80).aspx

pseudorandom21 166 Practically a Posting Shark

I'm taking a look at some of the code, my initial thoughts on your first problem are that the file stream has error bits set that need cleared.

Firstly as a matter of good style let's initialize your char array to '\0'. char fname[30] = {'\0'}; What this code does is ensure initializing the first element to '\0', and the way C++ works means it will zero the rest of the elements of the array that were not specifically initialized.

It appears the errors is indeed un-cleared file stream errors.

if (!fio)
			{
				cout << "File does not exist, try again? (y/n) ";
				again = getYesNo();
				cin.clear();
				cin.ignore();
				fname[0] = '\0';
			}

"fio" likely has error bits set that need be cleared, just like cin.


Hopefully this will make clear the issue:

if (choice == 'Y')
	{
		cin.clear();
		cin.ignore();
		do 
		{
			fio.clear();//<-- clear error bits.
			cout << "Enter the name of the existing file: ";
			cin.getline(fname, 30);
			fio.open(fname, ios::out | ios::in | ios::binary);//<-- set error bits on error.
			if (!fio)
			{
				cout << "File does not exist, try again? (y/n) ";
				again = getYesNo();
				cin.clear();
				cin.ignore();
				//As a matter of good style let's zero the array.
				memset(fname, 0, 30);
			}
		}while (again == 'Y' && !fio);//<-- test for error bits.
	}

Looks like this line was neglected:

fio.open(fname, ios::out || ios::binary || ios::trunc);

fio.open(fname, ios:: in | ios::out | ios::binary | ios::trunc); Some stuff is still left in your …

cousinoer5 commented: Thanks a lot for the help! :) +2
pseudorandom21 166 Practically a Posting Shark

Microsoft unicode stuff.

http://msdn.microsoft.com/en-us/library/aa272960%28v=vs.60%29.aspx

You will likely opt to use either the "char" type of string, or the "wchar_t" type.
Visual Studio provides a std::wstring.

http://msdn.microsoft.com/en-us/library/wt3s3k55%28v=vs.71%29.aspx

Note that wstring is a basic_string<> templated to wchar_t.

You may also opt to convert the "char" string to "wchar_t".
See MultiByteToWideChar: http://msdn.microsoft.com/en-us/library/dd319072

pseudorandom21 166 Practically a Posting Shark

It can be done but it's usually not easy, nor is it intuitive. I have "scraped" a website with C++, which means downloading a copy of the web page's HTML.

For your particular problem, wouldn't ftp be easier to use than HTTP ?

Scraping is a bad way to do it, but I did it...
with HTTP you'll connect to www.mysite.com then send a request for the page you want, it may look something along the lines of (but probably not exactly) this:
GET /check/check.txt

Anyway, unless you want to use some libraries for HTTP automation/stuff then you will be reading a lot of HTTP specification, and most of it doesn't tell you what you need to know.

That said, I highly recommend not scraping the web page. I haven't used FTP but I have written an SMTP client, and a POP client, and it is my thinking FTP is quite do-able. You may want to use a third party library for FTP also.

There are thousands of libraries for C++ (lucky us). Also, using a library will most likely save you a lot of time.

pseudorandom21 166 Practically a Posting Shark

Question #1. It's a C++ template, which is a powerful feature.
Question #2. You have two variables with the same name in the same scope. That's a no-no in every programming language I know of.

pseudorandom21 166 Practically a Posting Shark

I don't expect to be wasting my time, so I'll try to teach you a bit.

In your original code:

void Password()
{
		char pass[20];//array of 20 char variables.
		cout << "Password: ";
		cout << "\n";
		cin.get(pass[20]);//<-- as mentioned before,
//that line is calling the single character overload of the get()
//function of the istream class, of which the class instance 
//(variable, if you must)
// "cin" is an instance of.
//To see the available overloads please refer to the reference
//I posted earlier: http://www.cplusplus.com/reference/iostream/istream/get/
//Near the top of the page, in green text is the overload you are calling:
// istream& get ( char& c );
//Note, that you are calling this overload by specifying an index
//of the array, being [20] (which doesn't exist, 19 is the last as previously noted).
//by subscripting, i.e., [ ] the array you are specifying that you want
//to access a single element!

//I hope you know how pointers work, if not I don't think you will
//understand this fully.
//Because of the way pointers work, and the fact that in memory an array is
//allocated contiguously (think of a bunch of boxes in a line next to each other)
//the name you have given the array is implicitly a pointer to it's base,
//meaning, the pointer name points to the first element of the array,
//which is index 0.
//Thus, aha!  Each consecutive element can be accessed by incrementing the base
//pointer, or adding a number to …
altXerror commented: completely fixed my problem. +1
pseudorandom21 166 Practically a Posting Shark

I'm assuming the pointers point to dynamically allocated data, probably allocated with "new" ?

In that case, it is very important you do not lose track of the pointers that point to data allocated with "new". When you copy a pointer to the vector that has pointers in it, if you're over-writing a pointer pointing to data you may lose the only pointer to the location of the data in memory, and thus will leak memory.

It is my opinion that the proper way to do it is actually to use a smart pointer type, such as those provided by the boost lib. See boost::shared_ptr<>

Otherwise, if you must use raw pointers, delete the pointer you are going to over-write, set it to nullptr, then copy the new pointer over. If you wish the pointer to still be useful, do NOT call delete on the other copy of hte pointer in the other vector.

Instead, set it to nullptr.

Ex:

for(int i=0; i<m_vPopulation2.size(); i++)
{
	delete m_vPopulation2[i];
	m_vPopulation2[i] = m_vParentPop2[i];
        m_vParentPop2[i] = nullptr;//or NULL (0x0)
}
pseudorandom21 166 Practically a Posting Shark

He's using a 20 year old compiler that has a header file called "graphics.h", the compiler he's using probably produces 16 bit executables and supports non-standard C++.

Ahh the amazing Turbo C++, it's still used in universities, typically in India. Though, this poster's profile says Pakistan.

I would recommend OP use a newer compiler, and not pay for courses that use that compiler. Wasting money, IMO.

pseudorandom21 166 Practically a Posting Shark

It would almost be funnier if you used some turbo C++ headers.

jonsca commented: I have a special place in my heart for dos.h :) +6
pseudorandom21 166 Practically a Posting Shark

You could try implementing the sieve of eratosthenes using a vector<bool> or a bitset, the wikipedia page on the sieve is decent; the vector<bool> is for marking it as not prime.

The indices would be the numbers.

http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

You also have other options, of course. It is my belief that Era's sieve will be the fastest.
http://en.wikipedia.org/wiki/Sieve_of_Sundaram

Here, this according to wikipedia, is a modern version of Eratosthenes' sieve:
http://en.wikipedia.org/wiki/Sieve_of_Atkin

see also: http://en.wikipedia.org/wiki/Wheel_factorization
And, it's up to you as the master and commander of your project to determine the one that will suit your needs of both difficulty in implementation/time used and the required performance.

pseudorandom21 166 Practically a Posting Shark

This is not the appropriate place to beg for code.

Fbody commented: I prefer to give +rep today :) +5
pseudorandom21 166 Practically a Posting Shark

It's not managed C++ anymore, it's C++/CLI--there is a difference.

managed C++ had the horrible syntax, C++/CLI is actually kind of decent.

Ancient Dragon commented: good point :) +36
pseudorandom21 166 Practically a Posting Shark

Truthfully, my best advice to you is not make performance your #1 priority for every application.

Professional programmers, (and sometimes software engineers) will use the right tool for the job. That's what programming languages are, tools with which to solve problems. Native C++ (the ISO kind, not C++/CLI) is often used in performance-critical applications, and also is somewhat vendor independent. Many computer games are written with C++. Now having said that, it does have it's limitations, such as not having a standard way to create a Graphical User Interface. To create a GUI with native C++ will be different for Windows and for Linux. If you want to know more about C++ you can read the FAQ on Bjarne Stroustrup's (the creator of C++) website.

While C++ can be used for just about everything under the sun, and I do recommend you learn it if you intend to be a software engineer/developer/programmer--I myself would opt to use the RIGHT tool for the job.

Automating HTTP stuff is a real pain with C++, but the beauty of the beast is that there are so many libraries to assist with doing things like that (it's quite commonly used) it's almost a guarantee to find a library for doing many things from a quick google search.

Now I'm done ranting, but I want to say it is of utmost performance that you learn more than one programming language. .NET languages (like C# and C++/CLI) are Microsoft dependent, but allow …

jonsca commented: Good observations +6
pseudorandom21 166 Practically a Posting Shark

If I'm not mistaken .at() will throw an exception if the programmer tries to access an element beyond the bounds of the array--while operator[] will not.

Consequently, .at() may be less efficient (so I've heard).

pseudorandom21 166 Practically a Posting Shark

This may be helpful for you (Windows only): http://msdn.microsoft.com/en-us/library/ms810467.aspx

This may also be helpful: http://www.libusb.org/

seoforpakistan commented: How to use php as data base? +0
pseudorandom21 166 Practically a Posting Shark

Yes, you can get your input into a string and parse it.

#include <string>
#include <sstream>
#include <iostream>
using namespace std;

int main()
{
  string input;
  getline(cin,input);
  int value = 0;
  stringstream(input) >> value;
  if(value == 0)
     cout << "Invalid entry." << endl;
  cout << value << endl;
}
pseudorandom21 166 Practically a Posting Shark

May have to dynamically allocate the memory using "new" and "delete".

Also, in this line:

int fileTempSize = data.size();

int doesn't have the range of the unsigned int, make sure your fileTempSize is the same type as the type returned by data.size()

this can cause problems if the size is greater than std::numeric_limits<int>::max(), it will overflow the variable.

std::vector<char>::size_type fileTempSize = data.size();

Or if you have a compiler that supports the new "auto" keyword..

auto fileTempSize = data.size();