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

From what I read this morning Ford doesn't want or need any bailout money at this time. It is either going to fix its own problems by itself, or wait until next month when Obama will be in charge.

And Bush is going to nationalize the two remaining auto companies -- Crysler and GM -- by buying shares of stock for 17.5 Billion or so. That puts the government in charge of building cars -- a very very bad idea.

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

Doesn't the latest version of g++ support it? Maybe you just need to download the lastest version. GNU is usually pretty good at keeping those compilers up-to-date.

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

change #include <string.h> to remove the .h extension -- #include <string> That will not fix all your proglems will fix some of them.

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

Maybe this article will give you some hints on how to correct it. Also search that site for "flickering" because I found several other articles on that topic that may or may not be of interest to you.

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

Is this an MFC project? Try adding them at runtime in the OnInitDialog() (CDialog) or OnInitInstance() (CForm)

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

Please post your program -- maybe there is something else wrong with it. I don't have a *nix os so I can't really help you much.

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

Do you mean something like DaniWeb Community Feedback ?

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

I thought most modern c and c++ compilers supported some form of 64-bit integers. Try just "long long" instead of "long long int".

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

ExitThread() belongs inside a thread, not in main().

ExitThread is the preferred method of exiting a thread in C code.

There are other methods available to keep main() alive until the threads terminate on their own.

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

using namespace std;
unsigned __stdcall Display(void* p)
{
	Sleep(500);
	cout << "Display" << endl;
	cout << *((int*)p) << endl;
	return 0;
}
int main()
{
	unsigned taddr = NULL;
	unsigned createFlag = 0;
    HANDLE handles[5] = {0};
 	for(int i=0;i<5;i++)
	{
		if (handles[i] = (HANDLE)_beginthreadex(NULL,0,Display,&i,createFlag,&taddr))
		{
			cout << "success" << endl;
		}
		else
			cout << "failed" << endl;
	}
    WaitForMultipleObjects(5, handles, TRUE, INFINITE);

	cout << "main's execution is over" << endl;
}
Agni commented: Thanks +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>ExitThread(0);
delete that line in main()

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

About 1984, just before I retired from military, on their computer and their network.

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

>>most urgent

Maybe for you, but not for us. Describe the problem you have because we are not interested in just looking at your code and try to read your mind.

And next time try to be a little more creative in the title of your threads.

[edit]Merged your two threads. Don't start new threads for the same topic.

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

>>e.g. data1.c

The file extension is somewhat important -- *.c files are normally c programs, not data files. Your data file should be names "data.txt".

You need to store the data in an array of struct sale objects. What you are doing is just overwriting all the data on each loop iteration. So just declare an array and use it.

And a for loop would be more appropriate here than a while loop.

struct sale Weekly_Sale[13];
   for(i = 0; i < 13; i++)
   {
       scanf("%i %i %i %s", &weekly_Sale[i].week, &weekly_Sale[i].units, &weekly_Sale[i].price, weekly_Sale[i].name);
   }

Now it is a simple matter to store all that information in a file

FILE* fp = fopen("data.txt","wb");
if(fp !=  NULL)
{
     fwrite( Weekly_Sale, 13, sizeof(struct sales));
     fclose();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Also, even although TurboC is old, it is not freeware. It is still copyrighted software.

According to this definition I think it could be considered freeware, as would VC++ 2005/2008 Express, Dev-C++, and Code::Blocks. Freeware doesn't mean "not copyrighted".

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

If you have a small program with just one *.c file, then static functions aren't all that useful. The advantage of statics is with larger programs whose projects consist of several *.c files. In this case, as Narue already said, make all the functions static that do not need global scope to other *.c files. And the same with global data objects, make them static too if they don't need to be referenced in more than one *.c file.

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

please tell me the required site to download turbo c

Why? You couldn't use it anyway because you must be blind since you didn't bother to read this thread.

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

Welcome to DaniWeb. But please stop using ALL CAPITALS in the future because they say you are screaming at us.

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

It is not UNICODE -- its just a character from a special font. If you print that out (see below) you will see that it has a decimal value of -105.

int main()
{
    char c = '—';
    cout << c << " " << (int)c << "\n";
    return 0;
}

So in your program just check for a character whose ascii value is -105 and change it to --.

At least that's how it works on an American keyboard and Vista Home. Other keyboards might be different, I don't know.

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

Maybe that's why fish swim upside down :)

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

Looks like you will have to translate that C++ class to C, and that could be a huge chore.

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

Whose c++ compiler? Borland? Then you probably need a newer compiler because that one is pretty old and obsolete. You can download free several compilers, such as VC++ 2008 Express, Dev-C++ and Code::Blocks. Just google and you will find the links.

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

You will get quickest and best answers by posting on Maya's message boards.

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

>>however the .exe does run the .bat file with no problems
Then don't bother with my suggestion.

Sounds like the problem is with the program keytool. Open the batch file with Notepad.exe, copy the line into clipboard, create a command prompt, paste that line into the cmd prompt and then execute it. Does it work?

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

The problem could be the difference in environment variables or current working directory. In the system() line try adding the full path to that batch file and see if that works.

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

use nested loops

for(int year = 1; year < 2; year++)
{
    for(int month = 1; month <= 12; month++)
    {
        // blabla
    }
}
anbuninja commented: thanks +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why don't you spend $50.00 and go ask a lawyer that specializes in such things.

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

what you have should work -- but move it down outside that loop. You are getting strange charcters because it is trying to display uninitialized array elements which have not been filled yet.

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

I would think it would be a lot easier to work the the digits as strings instead of integers. For any given number:
1) Is it a single digit -- yes, then its a Palindromic number

2) If two digit number, are both digits the same: -- yes, then its a Palindromic number

3) for larger numbers, check if the first and last digits are the same, if yes, then check the second and next-to-last digits. Keep checking inwards until either no more digits or just a single digit left. If the algorithm gets that far, then its a Palindromic number.

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

which version of the compiler are you using? Did you first create a project in which you can add the *.cpp and *.h files? I think Microsoft has a tutorial that will teach you how to use the compiler. If you have VC++ 2008 Express just read the links here

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

>> sum = digit[counternumbers];
Two problems:
1) use += operator, not =

2)That is adding the ascii value of the digits. You need to convert to integer by subtracting '0', like this: sum += digit[counternumbers] - '0';

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

The Shift-Jis format is a Microsoft product. Get a PC running MS-Windows or Macintosh (running KanjiTalk) . I don't know if its possible on *nix.

http://www.futureimplications.com/japanese_file_formats/jfilefomats.htm

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

You will have to catch the WM_CLOSE event. Sorry, but I don't recall exactly which event handler you need to put that in.

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

Move lines 19-25 down within the loop to line 36 and it should work.

lines 47-99: You don't need to do that at all -- just save the sign in a char array so that they can be printed later at the end of the program. Since sign is a single character I guess you only enter single digit numbers.

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

yes that will work too. Please re-read my previous post because I added more.

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

lines 13 and 14: the size of the vectors is 0 because you have not assigned any elements to the vectors. Therefore the loop starting on line 17 will never execute because both s and decksize are 0.

similar lines 31 and 32 cause program to crash because deck does not have a size.

How to fix: before line 31 assign a size: deck.resize(52); Even despite the above problems that shuffle function doesn't work because rand() often returns the same value, so the shuffled deck will contain duplicate values. What you need to do is keep track of the values returned by rand(). Each time it generates a value, check the previous values to see if the new value has already been generated. If it has, then generate another number until it finds a unique number.

You also need to delete line 20 because erasing the contents of the vector willl also cause the program to crash.

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

>>P.S 1: I'm only a beginner
Then you are way way over your head. Learn the language before jumping into the deep water.

>>just tell me where can I put it
Do you really mean that :)

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

The answer to the first question is easy

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    cout << right << setw(20) << "Hello\n";
}

For the second question, there is no portable way to do that. Some compilers pre-define macros that indicate the compiler and compiler's version, while other compilers don't. So the only sure-file way to do it is to declare the macros yourself for each compiler you want to support.

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

"unresolved externals" means the linker can not locate the named function. In this case it is looking for CalcTaxesEx() and can not find it. Check the code you posted and you will see that it isn't there.

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

Look at the parameter for State_Tax() -- it is not a pointer. But you are trying to pass a pointer in Calculate_Taxes(). Change it to this: *statetax = State_Tax(*federaltax);

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

displayGrid() is called from playGame(), but playGame() is not called from anywhere.

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

why should it return anything? just make the function void.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
string toLowerCase (string s)

{
    string g=s;
    toLowerCase(g);
    return g;
}

That's not how to convert a string to lower case. Use the tolower() macro in a loop and convert each character

string toLowerCase (string s)
{
     string g = s;
     for(int i = 0; i < g.length(); i++)
        g[i] = tolower[g[i]);
     return g;
}

or you could do it this way in c++

string toLowerCase (string s)

{
    string g=s;
    transform(g.begin, g.end(), g.begin(), tolower);
    return g;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>char* sntnc;
That is just an unallocated pointer. If you want to use pointers then you have to allocate memory for it. char* sntnc = new char[255]; For the purpose of your program a better way is not to use a pointer char sntnc[255]; Or even better yet, use std::string std::string sntnc; >>cin>>sntnc;
The >> operator will not work if you want the user to enter some text that includes spaces. Use getline() instead. There are two versions of getline() -- one for std::string and the other for char*.

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

>> can any one help?
Yes -- but I can't see what you have attempted so you will just have to post your code here.

>>the input should not be case sensetive
Convert the input string to all upper or lower case. You can use the toupper() and tolower() macros for that -- they work on only one character so you will have to do it in a loop.

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

argv is an array of strings, not ints. You have to convert strings to ints before adding them answer += atoi(argv[k]); Other ways to accomplish it is to call strtod() or stringstream

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

try it, time it, and find out if it will make any noticeable difference.

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

There are thousands of tutorials, most of them are not worth the band width. Read about the books in the Read Me thread at the top of this c++ board and you will get lots of excellent suggestions.

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

you could use <map> to map the loop counter i with a string. A simple example, uses an array of maps to represent the 4 kinds of cards.

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

map<int, string> deck[4];
int main()
{
    deck[0][1] = "Ace of Spaces";
    deck[1][1] = "Ace of Clubs";
    deck[2][1] = "Ace of Diamonds";
    deck[3][1] = "Ace of Hearts";

    string kind = deck[2][1];
    cout << kind << "\n";
}
mrnutty commented: Even though I haven't learned this, this post is helpful because you made it clear of the use of <map> . Thank YOU +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Try commenting out the worker threads and see if that fixes the problem. If not, then you know something else is wrong. If the problem goes away then try uncommenting worker threads one at a time until the program is broke again.