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

The while statement on line 96 isn't quite right. It needs to check for end of list, such as the value of elt is greater than any value in the list. In that case the loop will continue beyond the end lf the linked list.

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

Post the whole program -- I'm not going to guess any more.

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

You must be doing something else that causes that '\n' at the end of the string. This works ok for me

int main()
{
    char *argv[20] = {0};
    std::string ip = "127.0.0.1";
    argv[1] = (char*)ip.c_str();
    std::cout << argv[1] << '\n';
    std::cout << "Hello\n";

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

line 5: wrong data type. Should be elementType, not int.

move lines 3, 4 and 5 down into the if statement. No point in doing that extra work when head is a NULL pointer.

line 20: at this point you need to allocate a new node to insert into the linked list. You didn't post getNode() so I'll guess that it just returns the node where the new node should be inserted.

nodeptr NewNode = new node; // I'm assuming the underlying structure is named "node"
NewNode->data = elt;
NewNode->next = insertPtr->nex;
insertPtr->NewNode;

line 30: What will that do if the value of n is greater than size()?

The delete function has a memory leak because it doesn't destory the nodes that are removed from the linked list.

while( currPtr != NULL)
{
   nodePtr hold = currPtr;
   currPtr = currPtr->next;
   delete hold;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You don't want to use those functions. google for "ODBC Tutorials" and you will learn how to read and update any SQL compliant database, such as MS Access, SQL Server, MySQL, Oracle, Sybase, etc. You will also need to learn SQL scripting language. google for SQL tutorials too.

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

The problem really isn't how to include windows.h but how to get the HDC parameter that most win32 api graphics functions require. I don't know how to get that either from managed code.

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

I mean that they are not part of the standard C or C++ libraries. Standard functions are defied by the c and c++ ISO standards committee and every c or c++ compiler must implement them. You will find lists of standard functions in most text books related to c and/or c++ languages. Anything not identified as standard is, by its very definition, non-standard.

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

non-standard functions. google and you will find out how to use them.

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

>>the "I keep a gun to defend myself from the government" position certainly won't find any help here.

But it sure would if all citizens were armed and willing/able to use them when Hitler took over Germany. And we would do the same if someone tried to pull a coup d'état in USA.

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

>>scanf("%c",t->wallet);

Scanf() %c requires a pointer to a character, but all you are passing is a char itself. Change t->wallet like this: scanf("%c", &t->wallet); The the same with other scanf() functions.

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

And did you read this part of the article? The cops were completely at fault for that killing, which should not have happened.

Three officers were tried for manslaughter and other charges surrounding falsification and were sentenced to ten, six, and five years respectively.

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

win32 api function CopyFile() can be used with any file type. Post your code so that we can see what you did wrong. When CopyFile() returns zero value, get the error number from GetLastError(). Then call FormatMessage() to get the error message text.

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

>>if( !isalpha(name[31]) )

That is wrong -- it is checking the 31st character in the array, not the first character. Replace 31 with 0

I suppose it should also be checking each character in the array, not just the first one. So you will want to make a loop to check them

int i;
int valid = 1;
for(i = 0; name[i] != '\0'; i++)
{
   if( !isalpha(name[i]) )
   {
     valid = 0;
     break;
   }
}
if( valid )
{
    // put all those print statements here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It doesn't matter how the string was generated. Take the example that firstPerson posted and modify it for use it in your program.

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

Yes it will help. By itself it won't get you a job, but it will get you in the door to get an interview. Its up to you to show your stuff (knowledge and skills) during the interview.

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

<deleted>

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

well then access the string just like you would the character array. Put this in a loop: if( !isalpha(name[i]) ) If name is std::string why are you not using std::cout instead of printf()?

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

how is name declared? Assuming name is a character array you will want to look at each character and use isalpha() to determine whether or not the character is a-z or A-Z.

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

For testing out the two programs you could do them both on the same computer. For more extensive tests use two computers (or computer and laptop) you connected via LAN. I don't think you can make your server program run on someone else's computer without their permission.

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

Look at the structure and figure it out for yourself what the problem is. Learn to do a little research on your own and it will save you lots of time and effort.

If you display the value of time_t all you will see is a very large number that means nothing to you. It is the number of seconds since 1970.

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

enter the time as normal and the program converts it to time_t

int hour = 10;
int minute = 30;
int duration = 4; // 4 hours
struct tm* tm;
time_t theTime;

theTime = time(0); // get current date/time
tm = localtime(&theTime); // convert to structure
tm->tm_hour = hour;   
tm->tm_minute = minute;
theTime = mktime(tm);  // convert struct to time_t

// now calculate the end time.  Just add the hours and/or minutes
// and the function mktime() will adjust all other values as
// necessary to normalize the structure.
tm->tm_hour += duration; // add the hours
theTime = mktime(tm);  // convert struct to time_t
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Problem 2: put the times and their duration in an array, then search the array. You might need to use the complete day and time in case duration is beyond 24 hours.

struct booktime
{
   time_t starttime;
   time_t endtime; // start time plus duration
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have to make them a string, such as

char buf[40];
int hour = 1;
int minute = 25;
sprintf(buf,"%02d:%02d", hour, minute);

That's the easiest way to do it. It can also be done using stringstream.

Or if all you want to do is display them cout << hour << ':' << minute << '\n';

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

the loop should be something like this. And do not dynamically allocate array a because it is causing you a memory leak (your program doesn't delete[] it). The array size is small enough that dynamic allocation isn't necessary anyway on most modern operating systems such as MS-Windows and *nix.

int povtorenie(struct node* call)
{
	char a[20];
	strcpy(a,call->regnomer);
	call = call->next;
	while(call!=NULL)
	{
		if(strcmp(call->regnomer,a)==0)
			return 1;
		call = call->next;
	}
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is why we need guns for protection. I just love stories like this with happy endings :)

Glass_Joe commented: Best grandma ever +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why did you create two threads for the same problem??? See your other thread for solution.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
/* initialise triangular matrix to zero */	
for(i =0; i < dimention; ++i)		
   for(j =0; j <= i+1; ++j)			
    lower_tri[i][j] = 0;

The above causes buffer overrun. The inner loop should be < not <=

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

the array has to be deallocated in the reverse order that it was allocated

for(i =0; i < dimention; ++i)
	free(lower_tri[i]);
free(lower_tri);

If you get seg fault with that then it means the program has been corrupted somewhere.

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

If you are using VC++ 2010 (or 2008) you can create CLR Forms application in which you can easily create text boxes to display the information from the file. google for clr tutorials and you will find out how to do that.

I though you said the program reads the data from a text file. But with #6 I'm not so sure.

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

Yes, I actually had the statement backwords -- should have been == 0 as previously noted.

The not operator ! means 0, not false. There is no requirement for false to be 0.

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

There is no such thing as = !!. What you want is != 0

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

One common c++ exercise is: Write a recursive function that gathers a list of all the files and folders on the hard drive, starting with a folder specified by the user. You will need to maintain either a std::vector or std::list (your choice) of all the files, and the file names must contain the complete path. When finished, short the array or list alphabetially by calling std::sort and supplying it your own comparison function. Display al the files after the vector or list has been created. Note: Don't copy/paste code you might find on the net -- that's considered cheating.

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

Stack::Node says Node is a structure defined inside class Stack.

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

why are you calling malloc() is a c++ program? Change it to new and see if that fixes the error. If not, then the real problem is in parts of the program that you did not post.

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

Yes, MFC has a database class, but its not really very good when it comes to complicated requirements. If all you need is a single table using simple selects and updates the MFC classes will work well.

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

You said in your original post that you wanted to know the number of passes through the loop that it took to either find the number or determine that the number was not in the array. Otherwise the count variable can be deleted because it servers no other purpose.

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

The oldest and most common method is via ODBC. Its pretty complicated stuff. There are a few c++ classes, use google to find them too.

Another method is ADO, Microsoft has an ActiveX control for that.

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

That's not binary search that I learned. looks more like linear search.

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

USA has millions and millions of visiters each year to see such places as Disney Land, Disney World, etc. Almost none of those visiters (tourists) have any problems at all, unless they are looking for problems. I doubt you will see a single person walking down a city street carrying a gun. We aren't the wild west you see in the movies.

Mexico is a different story because of the war the drug lords are having with their government. Its especially dangerous along the Mexican/American border.

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

Where in the world did you get that binary seach algorithm??? It isn't nearly that hard.

void bsearch(int a[], int size)
{
    int n = 0;
    int high,low,mid,count;
    printf("Enter number to be searched\n");
    scanf("%d", &n);
    getchar();
    high = size;
    low = 0;
    count = 0;
    do {
         mid = low + ((high - low) / 2);
        if( n > a[mid])
            low = mid+1;
        else if( n < a[mid] )
            high = mid-1;
        ++count;
    } while( a[mid] != n && low <= high);
    printf("count = %d\n", count);
    if( low > high )
        printf("%d not found\n", n);
    else
        printf("a[%d] = %d\n", mid, a[mid]);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Conversion is not necessary. The char data type is a one-byte integer.

char x = 2;
int y = x;

The compiler will promote the char to int during the assignment.

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

I'm not a mind reader nor am I clairvoyant.

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

Not a macro, but you can easily write a function to do that. Give it a try and see what you can gome up with.

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

There is no point in dynamically allocating small amounts of memory. One advantage of usiong cUser[5][10] is that is is not prone to memory leaks.

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

turbo c is a 16 bit compiler and can not access win32 api function. So you can't create a windows app with it. Get a modern compiler such as Code::Blocks or VC++ 2010 Express (both are free).

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

LPCTSTR is typedef'ed in windows.h as const char* . So your String class will want to return a char* pointer to its character array, or whatever kind of data it holds.

class String
{
private:
   char* str;
public:
   const char* operator LPCTSTR()
   {
         return str;
   }
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You made incorrect changes. Delete the allocations on lines 9 thru 12 and just hard code their sizes char cUser[5][10], cPassword[5][10]; Since cLoginU is declared to contain only 10 characters, then cUser should be the same size.

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

>> char *cUser[5]
That declares an array of 5 pointers. Are you attempting to store 5 different use names in that array? If you are, then you have to allocate memory for them before they can be used. There are a couple ways to do it

1) use static allocation, such as char cUser[5][25]; which will have enough space for 5 user names, each name as maximum of 24 characters + null terminator.

2) allocate them with malloc

for(i = 0; i < 5; i++)
   cUser[i] = malloc(25);

The same applies to cPasssword.

But for the life of me I don't know why you would want to user to enter 5 differet user names and passwords? Why not just one ?

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

>>fyi the police are there to protect individuals
No they are not. The police are not your personal bodyguard. There are not enough police to be everywhere and protect everyone. It is your responsibility, and yours alone, to protect yourself and your family.


In America I have the right to use deadly force against any uninvited intruder. Robbers generally do not attempt to rob homes where they know someone is at home, but it does happen and many of them are shot dead. When that does happen the robber had better be inside the home. If he is not then the shooter may be convicted of murder, unless there are other circumstances that can show the murder was justified.

>>Is it not better to leave it to the police
No because its not the police's job to protect every person and every home. If you wait for police the robbers will be long gone with either the goods or your life.

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

A composite key means the key consists of two or more fields.
"select price from item_size where field1 = "something" and field2 = "smethin else" and ..."