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

Well then tell your friend to start making google his/her first option. He can't learn to program if you do all the work for him.

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

+= is ok there because he's using std::string

Your program probably needs to check for sql errors on return because it could be some other problem, such as not logged into mysql.

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

You need to learn how to use google to find the class as that will save you many hours time waiting for someone to give you the info you want. In this case all you had to do was google for CComboBox and select the very first link that it gives you. At that link, which is in MSDN, you will find a list of all the methods which you can use. In this case you want AddString(). I'm not going to tell you how to use it because I think if you are going to work with MFC you need to learn how to do it yourself.

Happy programming :)

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

What operating system and compiler? What GUI platform (e.g. win32 api, MFC, Windows Forms, wxWindows, etc)

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

You need to first get the current date from the computer's clock. Use the functions in time.h, time() returns the date/time in seconds, then call localtime() to covert that into a struct tm. Next convert user's birth date into month, day and year integers, then just subtract from struct tm. It's not a straight forward subtraction, so you might want to do it a couple times by hand using pencil & paper in order to get the algorithm straight in your mind.

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

something like this, note the two stars, one star for each dimension in the matrix. Assumes matrix was defined something like double matrix[m][n]; If it is only declared as double matrix[m*n]; then use only one star below instead of two.

double** Matrix::read()
{
    return matrix;
}

then somewhere in main()
double** matrix = image1.read();

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

or

while( in_stream >> name >> combo >> op1 >> op2 >> op3 >> op4)
{
   // do something with the data
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

at line 29 you are setting seconds back to 0. So it's an infinite loop.
Use a different variable in for loop condition.

Oh yes, I hadn't noticed that.

The program can be greatly simplified

in main()
{
   wait(90); // wait 1 1/2 minutes
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The timer is set to run for about 90 secndxs. Why do you think it should run until 1:30 ?

>>if(seconds == 90)

Impossible. The loop will stop as soon as seconds == 90, so the statement above will never get executed.

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

>>I'm trying to display the contents of a matrix without using "cout" in my class

Huh?? How do you plan to display something without using either cout or printf()? one way to accomplish that in MS-Windows is to call WriteFile() instead of cout.

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

Visual Studio most certainly does contain a c++ compiler. You can get vc++ 2010 Express for free, as well as vb.net and C#. It's the best compiler suite there is for .net framework, afterall it is produced by the same company that wrote .net -- Microsoft. You can't get a better compiler suite.

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

>>using #include <cnum.h> does not help..

Correct. When angle brackets are used, the compiler looks in the directories that are shown in Project --> Properties (at the bottom of the menu), Configuration Properties --> VC++ Directories. You can customize that to include whatever directories you want.

>>or is there a way to create a .lib file out of a .a file?
there is no conversion program that I'm aware of. Maybe they will give you the source code so that you can compile it yourself with vc++.

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

If user enters wrong data then display an appropriate error message then re-display the original question. Best way to do that is to put all that in a loop and break out of the loop only when user enters correct data.

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

English please! We don't speak/read/write German.

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

>>(*bags[0]).someReceiptBagFunction();

Or, more simply bags[0]->someReceiptBagFunction();

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

why not just make the array of pointers (note that arrays of references are illegal).

ReceiptBag zero("zero");
ReceiptBag one("one");
ReceiptBag * bags[] = {&zero, &one};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>for(k=1;k<=900000;k++);//increasing this value will slow down the cursor speed.

Horrible waste of CPU time! That is dependent on CPU speed. In Turbo C call its delay() function.

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

If you surround the name of the include file with quotes the compiler will expect to find it in the current working directory (where the .c or *.cpp files are found).

>>libCNum.a
VC++ 2010 may not recognize that file format. They usually have *.lib extension.

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

Thank You for tha Information sir... but my problem that i can move/manipulate the cursor left, right, down, up in the output screen.

Hope you can help me...

He already told you how -- call gotoxy().

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

Do you want to know how to write a 1d matrix out to that file or read the file into the 1d matrix?

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

It's not all that difficult to do. Here's an example of push_back

const int BlockSize = 10; // allocate this number of elements at one time
int MaxArraySize = 0; // initial size of the array
int CurrentSize = 0; // current number of elements used in the array

char** array = 0; 

void ReallocArray()
{
   MaxArraySize += BlockSize;
   array = realloc(array,MaxArraySize);
}

char* push_back(const char* item)
{
    if( (CurrentSize+1) >= MaxArraySize )
    {
       ReallocArray();
    }
    array[CurrentSize] = malloc(strlen(item)+1);
    strcpy(array[CurrentSie], item);
    ++CurrentSize;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The only way I know how is to use either termcap library or curses. Unlike MS-Windows, *nix supports a huge variety of monitory, keyboards, and terminals.

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

If you remember something clearly, there's no need to review. It's only when forgetting something keeps you from understanding new material that you need to go back and review what you forgot.

Unless, of course, you don't remember what you forgot :)

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

google for "mixed language programming" and you will find quite a bit about that topic. Its easier to mix C with other languages than it is c++, but it can be done. C++ will probably need some C wrapper functions in order to mix them with other languages because of the way c++ compilers mangle function names.

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

Don't worry -- what you are experiencing is a common problem; forgetting. Keep on practicing as often as you can and you will eventually be able to remember it. Its very similar to learning to play a musical instrument; it takes lots and lots of practice.

If you forget what you read in those books then re-read them. I always kept two or three books at my side all the time while coding so that I could look up the things I forgot.

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

Compile for debug mode then single step through the program so that you can see where the problem is. How to do that will depend on the compiler you are using.

>>vector<int>* readDice(vector<string>& anImage) {
That function is attempting to return a pointer to local variable. And, like all local variables, that is destroyed immediately when the function returns, so the receiving function is getting an invalid pointer.

A solution to that problem is to add another parameter which is a reference to a vector that is created by the calling function, e.g. void readDice(vector<int>& result, vector<string>& anImage) { you really need to learn how to use your IDE's debugger because there are lots of other errors in that program.

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

No. The type between < and > in vector must be a data type, not the name of a variable. vowels is not a datatype.

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

Below are the messages I get. common.lib is built ok, but df_debug is not because of the error on line 24

1>------ Rebuild All started: Project: df_debug, Configuration: Debug Win32 ------
2>------ Rebuild All started: Project: common, Configuration: Debug Win32 ------
1>Build started 2/14/2012 10:27:20 AM.
2>Build started 2/14/2012 10:27:20 AM.
1>InitializeBuildStatus:
1>  Touching "Debug\df_debug.unsuccessfulbuild".
2>InitializeBuildStatus:
2>  Creating "Debug\common.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1>  df_debug.cpp
2>ClCompile:
2>  common.cpp
1>  dbgassert.cpp
2>Lib:
2>  common.vcxproj -> C:\dvlp\code\code\Debug\common.lib
2>FinalizeBuildStatus:
2>  Deleting file "Debug\common.unsuccessfulbuild".
2>  Touching "Debug\common.lastbuildstate".
2>
2>Build succeeded.
2>
2>Time Elapsed 00:00:00.76
1>c:\dvlp\code\code\df_debug\dbgassert.cpp(3): fatal error C1083: Cannot open include file: '../df_common/strtools.h': No such file or directory
1>  Generating Code...
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.30
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why are you trying to assign an array of pointers (str) to a single string? Also you failed to heed my warning about argc. If you want to do anything useful you have to start from argv[1] to argv[argc-1], not the other way around. Western languages read from left to right, not the other way around, and that's the way they are represented in argv.

// ArgParse.cpp : Defines the entry point for the console application.
// How can you refer to a character in a string? This does not work !!!

#include "stdafx.h"

#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>

#define STRINGSIZE 128

int main(int argc, char *argv[])
{
	char ch;
	char *str;
	int c = 1;

while (c < argc) {
	printf("arg %i - |%s|\n",c,argv[c]);
	if (argv[c][0] == '-') {
		printf("|%c|\n", argv[c][0]); // then show what it is 
             // assume the option string immediately follows the - symbol
             if( stramp( &argv[c][1], "Hello" )
             {  
                 printf("%s\n", &argv[c][1]);
             }
	}
	c++;
}

system("PAUSE");
return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

zip up all files and attach so that we can see what you did

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

>>Let me talk about a misconception. In human terms, it sounds more efficient to “Put all the new data at the end” and “Sort the whole list once” than to “Read through the list to figure out where each items goes” and “Do this for every new item”.

Good in theory, but it doesn't work like that. For linked lists with large number of nodes it is more efficient to sort at the end, as my previous post proved. Compile and run the program yourself to see the difference. The time difference becomes even greater as more and more items are inserted. I'm not saying you should sort at the end for every linked list -- only those with lots of nodes.


>>No one used relational databases. That could be because it was really hard to implement a relational database with punched cards
Apparently someone used them because they came into use during mid-1960s -- like shown in this wiki article. But you may be right if you was programming before then.

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

>>c--;

The initial value of c is too large. The value of argc is the number of strings in the array. So it counts from 0 to argc-1. You should make the loop as you would when using any other array

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

If you would rather use a while loop, then

int c = argc-1;
while( c )
{

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

LPCWSTR is a pointer to TCHAR so just use the & address operator to make the conversion
TextOut (hdc, 40,40,&chCharCode, 1);

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

I use Chrome and never have that problem. Most likely a problem with the cookies on your computer. If you delete the DaniWeb cookies then yes, you will have to log in manually again.

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

do you know how to write a for loop? If not, then here is a tutorial

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

[edit]Same as what ^^^ said.

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

Google for "System::Drawing::Font::Size" and you will find out what it is. Size returns a float. You can not use it to set the font size.

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

Size is read-only meaning you can't change its value.

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

I wrote a test program to test my theory. The program contained two test cases, both created a linked list with 100,000 nodes and called clock() to time each of them.

case 1: linked list that inserted new nodes in correct places, searched sequentially from the beginning of the list and stopped when the correct position was found.

case 2: Inserted all new nodes at the tail end of the list, then used bubble sort algorithm to sort them.

Result: case 1 = 83413 clock ticks, case 2 = 37,753 or less than have the time of case 1. The time difference could be even greater had I used a more efficient sort algorithm.

#include <ctime>
#include <iostream>
#include <cstdlib>

struct node
{
    struct node* next;
    int data;
};

const int MaxItems = 100000;

void insert(struct node**head, int newdata)
{
    struct node* n = new struct node;
    n->data = newdata;
    n->next = NULL;
    if( *head == NULL)
        *head = n;
    else
    {
        struct node* curr = *head;
        struct node* prev = curr;
        while( curr && curr->data < newdata)
        {
            prev = curr;
            curr = curr->next;
        }
        if(curr == *head)
        {
            n->next = *head;
            *head = n;
        }
        else
        {
            n->next = prev->next;
            prev->next = n;
        }
    }
}

void ShowList(struct node*head)
{
    while(head->next)
    {
        std::cout << head->data << '\n';
        head = head->next;
    }
}

void FreeList(struct node** head)
{
    struct node* n = *head;
    while(n)
    {
        struct node* h = n;
        n = n->next;
        delete h; …
WaltP commented: Very kool! Thanks. +17
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

shoot someone, sue the gun manufacturer (oops! they've already done that). Get drunk, have car accident which kills someone, sue the bartender. (already done that too)

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

I've never understood all this sorting of linked lists. Why not just add the node between the nodes containing the values above and below the new node? Just add them in their sorted position!

That would be ok for small lists, but this one will contain thousands of nodes. In that case it will be a lot faster to just add new nodes to the tail of the list and then sort it when its all done.

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

If you are going to add thousands of nodes to the linked list then don't sort anything until after all the nodes have been added. Then sort only once.

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

>>is there a way i can implement my insert function so that everytime it inserts a number it inserts it on the correct place

Of course there is. Just start at the beginning of the list and check each node for a value that is either < or > the newvalue (depending on whether you want ascending or descending sort). If found, then insert the new node in the correct location, adjusting next pointers as necessary. If not found then the new node just goes at the tail of the list.

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

To append data to the existing file you have to add another parameter to the open() statement myfile.open ("Sold Tickets.txt",ios::app); See the options in this link

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

We have fee wifi in a lot of places arond here -- gas stations, hospitals, McDonalds, and other businesses. These places even have signs on their buildings -- "Free Wifi". I agree with Grumpy, the judge should dismiss the case because free wifi has nothing to do with piracy. That's as bad as trying to sue the DOT (Department of Transportation) for car accidents because it happened on their (almost) free roads and highways. DOT would have to make them all toll roads to avoid such law suits in the future.

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

The first function is incorrect

void print (string word)
{
	cout << word << '\n'; // display the string
}

Now do similar for second function, but this time put cout statement inside a loop.

zeroliken commented: simple as that +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why do you think CB doesn't support DirectX? or graphics? Have you read any of these tutorials?

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

If you are wanting to learn win32 api, then this is a good introduction. But it is far easier to use a different language, such as C# or CLI/C++ (Windows Forms)

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

Here's a link for MS-Windows (and it won't matter which 32-bit compiler you use. It won't work with Turbo C or Turbo C++)

DeanMSands3 commented: Rock on, Ancient Dragon. +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

But wouldnt an enum be limited to the size of an int. I need to be able to store a massive set of independent values, 32 bits will not be enough.

If it will fit in a 64-bit integer then you could use either const long long x = ??? or (Microsoft compilers) cost __int64 x = ???