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

>>myValue= new char[sizeof(textVal)];
That won't work because sizeof(testVal) is nothing more than sizeof(char *), or 4 on most 32-bit compilers. What you want is myValue= new char[strlen(textVal)+1] then on the next line call strcpy() instead of memcpy().

Those two lines can be combined like this: myValue = strdup(element->GetText()); . To destroy the memory call free() instead of delete[] because strdup() is a C function that uses malloc().

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

Is that trying to compare the first two characters of each std::string? if( number.substr(0,2) == myvector[x].substr(0,2))

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

Put the questions is an array of strings then you can use rand() as an index into that array. Something like this

char *questions[] = {"one","two","three","four","five"};
srand((unsigned int)time(0));

do
{
   int index = rand() % 5; // 
   cout << questions[index];
} while(true);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what do you mean it doesn't work?? I use system("cls"); occasionally and never had a problem.

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

line 19: What exactly do you expect sizeof() to return on that line? Answer: sizeof() is returning the size of a pointer, not the length of the string to which it points. In otherwises use of the sizeof operator on that line is meaningless.

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

1. use a loop

2. call srand( (unsigned int)time(0)); to initialize the random number generator, then for each number call rand() to get a random number.

3. google for sort algorithms. The bubble sort is the easiest to code but the slowest. In c++ you can also use the std::sort() method found in <algorithm> header file.

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

what data type does lid2pstr() return?

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

If you don't use code tags then nobody will look at your program. Also you need to tell us what problem(s) you are having with it, what compiler and operating system you are using. Afterall, we are not mind readers.

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

Well you obviously can't change the original pair class, so subclass it and do your own thing.

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

NULL is traditionally meant to only be used with pointers, never integers or characters because originally NULL was defined as #define NULL (char *)0 So to check for the string's terminating character it would be for(size_t n = 0; myStr[n] != 0; n++) C++ now normally defines NULL as 0, so the compilers that define it that way will not have a problem with using NULL instead of 0. However, just be aware that such a program may not compile with all compilers.

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

Write your own pair class and implement the == operator any way you want.

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

Those errors are the result of something completely different than you stated in your original post. Those errors mean that you did not link your program with one or more libraries. Find out what library those functions are in and add it to your project.

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

>>please can any one write the code without using pointers
I don't think that's possible.

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

Probably some file(s) need to be recompiled. Select menu Build --> Clean Solution, then rebuild the solution and that normally fixed the problem.

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

>>OR my question is meaningless.
It doesn't matter whether you disagree with us or not. It can't be done the way you want to do it. So further discussion on that is meaningless.

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

You have to do it with a gui program -- can't be done with console. Here is a tutorial about how to get started writing MS_Windows gui programs. After you learn the basic then you need to learn all about fonts and how to manipulate GDI objects.

I know you thought you had a simple question, but the answer is pretty complex.

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

You have 500,000 mentors right here at DaniWeb. Just ask and someone will be glad to help with whatever problems you have.

And BTW software development is still alive and well here in USA and most likely in Europe too.

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

main() has to return an integer, not anything else such as char*. Replace that return statement with something like this: return 0;

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

Never try to crete a file in the root folder of C: because you may not have persmissions to do that. Move it to a different folder that.


void main() -- main() always returns an integer, never void. Some compilers may permit void but that is non standard and will not compile with many compilers. So to be strictly according to C++ standards you must declare main as int main() , or with optional parameters.

After getting the menu choice in main() you need to flush the '\n' Enter key from the keyboard buffer. If you don't then the next getline() will not work. Read this thread about how to do that.


Here is why the loop doesn't work right
>>while (choice == 'Y' || choice == 'Y' );

One of those two 'Y' should be lower case :)

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

>>if(a==1|2|3|4|5|6|7|8|9|0<b&c&d&e&f&g)

comparisons don't work like that in C or C++ languages. First off, variable a is only one digit, so why are you bothering to check that it is a number between 0 and 9? There are no other possibilities.

Put all the numbers in an array so that they can be easily sorted from hightest to lowest. After that all you have to do is print the first and last numbers in the array.

If you have not learned arrays yet, then you will have to do something like this, which can be very very awkward, error prone, and wordy.

if( (a<b) && (a<c) && (a<d) && (a<e) && (a<f) && (a<g) )
{
    // blabla
}
else
if( (b<a) && (b<c) && (b<d) && (b<e) && (b<f) && (b<g) )
{
    // blabla
}
// etc etc for all possible compinations if the 7 digits
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The compiler is not the problem -- the problem is that no 32-bit operating system will support such a huge array. Even a 64-bit os and 64-bit compiler will have problems with it.

You will just have to redesign your program so that it doesn't need tnat array. For example, you could put the data in a disk file and work from that, as Mike has already suggested.

If you keep insisting on doing the whole big array thing that great -- be stubborn and your project will fail.

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

Its all in the file extension -- *.cpp is c++ and *.c is C. After you create a c++ console project just rname the *.cpp file to *.c. Or you could create an empty console project and add *.c files to it.

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

Work with that other thread which is about the same identical program. I'm not about to get involved in two different threads with the same identical problem. Its too confusing for everyone.

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

Well that's possible too. Afterall, Chinese people see text on their computers in Chinese language. But I have no idea how they do it other than to say they have to use UNICODE.

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

>>One other factor which complicates my situation is that I have a felony
As an adult or a juvenile? And how recent? Your chances of getting a US Government related job (or a job with a contractor who has government contracts) is slim to none.

Sounds like you want to be a career student??? Don't get too many different degrees because that might hurt you too, such as like becoming over qualified for a job.

>>Has anyone followed a similar path?
Not me.

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

Lots of people all over the world write c/c++ programs in languages other than English. However, the c/c++ keywords are all in English. I haven't seen another compiler that use non-English keywords, but that doesn't mean there aren't any.

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

>>Is there meant to be more code after the sqlite3_exec function

No. The code I posted is a complete working example.

>>is it possible to replace the callback function with just the integer 0
I'm not sure what you are asking. The callback function is called for each row in the resultset.

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

Apparently Microsoft no longer supports that program. The bin.exe in the link I gave you most likely is no the same one you have.

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

That is pointer to a function that returns char*. __cdecl is a calling convention, which is a method used by compilers to pass parameters on the stack and clean up the stack when the runction returns to its caller.

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

That's bad news. We needed Borland as a competitor to Microsoft. I suppose M$ now has about 90% marketshare of the compiler market.

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

NODE_WATER_ATTR_ENABLE is a function and Attrribute() wants a char*. Try this: element->Attribute (XMLNodeNames::NODES::NODE_WATER_ATTR_ENABLE());

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

Yes it is c++. Just ignore the c++ stuff and concentrate on how to do the same in C.

I translated it into C and posted it in that same thread. Scroll to the last post in that thread to view it.

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

No, but I have a notebook. Will that be sufficient for whatever you want it for?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
StuXYZ commented: Nice comment, amused me. +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First you will have to move the declaration of that structure that's in addrecords() up to the top of that *.cpp file so that it can be used everywhere in the program, not just in addrecords()

Have you tried to compile all that code? I'll bet you haven't because I don't see where the variable system that's used in function retrieve() has been defined anywhere.

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

okay, i feel bad now. despite being dependent on legacy libraries, this is some nice looking code ... and the particular problem is an interesting one. i guess that's why i was disappointed i couldn't compile it.

But I also see now that the OP is an experienced programmer who used Borland back when it was top of the line in the 80s and early 90's. .

it's just a shame that today Borland focuses more on cornering the burgeoning Second World market than updating their compilers to the 21st Century.

perhaps in the future banders7 will just check that his code is compilable on MSVC or gcc or MinGW compilers as well as Borland.

Borland does have modern 32-bit/64-bit compilers, they are not free. The only free Borland compilers are ancient and obsolete. I can't vouch for how good or bad the newest Borland compilers are because I don't use them. But since Borland is still in business I suppose enough people/companies are buying them to keep them alive.

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

My version of Windows 7 does not have a bind.exe, and it isn't in the Windows SDK/bin directory either.

According to this bind.exe may be a virus.

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

Are you now talking about a c++ program instead of assembly?

>>Can you give me one exameple in code

You should be able to find examples on the net. I have not done assembly in quite a few years.

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

>>int &array

That does not create an array. All it is is a reference to an integer. If you want an array that you have one of two choices void foo(int array[]) or void foo(int *array) or just return the array

int* foo()
{
    int *ay = new int[5];
    for(int i = 0; i < 5; i++)
        ay[i] = i;
    return ay;
}

int main()
{
    int* ay = foo();
    delete[] ay;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

for starters line 14 does not allocate memory for the string's null terminating character. So line 23 writes beyond the end of the character array.

line 28 should be delete[] string; line 42: pass strings class by reference int operator==(strings& obj)

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

Are you too lazy to read this thread?? -- your question has already been answered.

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

You mean this??

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

>>Am i doing it right?

No. The code you posted will try to read the last line of the file twice.

ifstream in("inpufile.txt");
ofstream out("newfile.txt");
while( getline (in, str1) )
{
    out << str1 << '\n';
}

>> And will this work on MFC project?
Yes

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

First of all get a different compiler because that one is old and obsolete. Get either Code::Blocks/MinGW or VC++ 2010 Express, both are free.

Now you have a choice of using pure win32 api functions for graphics, or wxWidgets c++ class library (there are probably others too.) Both have online tutorials that you can easily find with google.

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

The simplest way to get that value is to use the return value of the sytem() function. See the example here.

A slightly more complex example is to launch the new process with CreateProcess() win32 api function, WaitForSingleObject() to wait until that preocess terminates, then call GetExitCodeProcess() to retrieve the return value from main(). This is more complicated than using system() but gives you a lot more control over the newly created process.

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

Well, as I already said look at the functions for int 21h. One of them checks to see if anything is available in the keyboard buffer and another will get it. So first you have to declare a buffer to store the string then call those two functions to fill it up wih the keystrokes.

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

What flavor of assembly? Not all assembly languages are equal.

For 80x88 assembly, look at the functions in int 21h.

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

>>it will reach the end of the main function and returns a "0" and tell the caller that "i did my job"!

Only if you do not specify a return value or you specifically return 0 in the return value. There is nothing to say that main() can not return something else even if it did successfully processess everything. The compiler itself could care less what main() returns as long as its an integer.

As one example of how the return value might be used, I wrote one program many years ago whose return value was used in a batch file to determine what actions to take. The C program had a menu of items from which to choose, and returned from main() the chosen menu item number.