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

That will only work on MS-Windows if you use MinGW compiler -- I know of no other compiler that has that non-standard C function. fgets() will work almost like getline() but there is no equivalent to getdelim(). Too bad they aren't standard C functions because they both seem to be pretty useful.

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

hi thx for reply, but i will be grateful if you suggest corrections in my existing program !!!!

I did. My suggestion is to rewrite it. The code you posted is much more difficult than it needs to be. There's such a thing as over-thinking a problem.

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

>>case 0: state = "Alabama";

You need to pass state as a pointer to a pointer, and statenumber should probably be an integer instead of char.

void writestate(int statenumber, char** state)
{
    switch(statenumber)
    {
         case 0: *state = "Alabama"; break;
         <snip>
    }
}

int main()
{
    char* state = 0;
    writestate(0, &state);
}

If you want state to be a character array as you posted it, then use strcpy instead of = to set its value

void writestate(char statenumber, char state[])
switch (statenumber[0])
{
case '0': strcpy(state, "Alabama); break;

Note that since you declared statenumber as a character array then you have to use '0' in the switch statement. That also limits the range of state to only 9 states -- '0' to '9'. For that reason its better to declare statenumber as an integer.

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

@Saba: The code you posted is pretty bad. It uses void main() instead of int main(), uses depreciated header files (c++ no longer uses .h extension in its standard headers), and mixes C and C++ strings, and adds absolutely NOTHING to the thread that has not already been said.

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

More than likely that program (Form1.exe) is still running in the background. Do Ctrl+Alt+Del to get tack manager then look at the list of running applications. If Form1.exe is listed there then try to kill it. If not, then you may have to reboot your computer to get it out of memory. I get that problem too on rare occations because the program will die to to program bugs.

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

get all input first using fgets() instead of that loop. Then to remove trailing white space start at the end of the string, search backward for the first non-white-space character and truncate the string at that point.

If you also want to remove instances of two or more white space characters inside the string, then use a pointer to find the beginning of the sequence, another pointer to find the end of the sequence, then call strcpy() to shift everything left, overwriting the excess white-space characters.

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

My password contains the name of an artifact from one of my favorite TV shows plus some numbers. And I use the same password everwhere, including DaniWeb. I've been told that an ideal password that would be very difficult to crack would contain at least 8 characters, at least one UPPER CASE character, one lower-case character, two numbers, and two non-alphabetic or non-numeric characters (such as ~,.-+ etc)

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

>> Y we use DLL files?

Answer: Y not?

>>where we should use DLL files and where not
DLLs are never actually required -- the same thing could be accomplished by using statically-linked libraries. But then that would make the operating system and all the programs on it very very huge. You might not have a large enough disk drive to hold all that duplicate code.

One case is internationalizing programs. Instead of writing a whole program for each language (e.g. Entlish, Spanish, German, Chinese, etc) it can be done by writing language-specific resource DLLs. One program, many language-specific DLLs.

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

This is one interpretation:

"Don't worry about the world coming to an end today. It's already tomorrow in Australia." Charles Schultz, creator of the Peanuts comic strip. 4

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

I was finally able to get it to work by opening the file in binary mode, not text mode. In binary mode the buffer will contain "\r\n" at the end of each string

#include <stdio.h>
#include <ctype.h>
#pragma warning(disable: 4996)

int main()
{
    FILE* fp = fopen("c:\\dvlp\\test.txt", "rb");
    if( fp != NULL)
    {
// The first two bytes of a unicode file contain -1 and -2 respectively, which is the unicode signature.
        char b[2] = {0};
        wchar_t iobuf[255] = {0};
        // read the unicode signature bytes
        fread(b,1,sizeof(b), fp);
        // read the rest of the file
        while( fgetws(iobuf, 255, fp) )
        {

            size_t len = wcslen(iobuf);
// Strip off trailing '\r\n' from the string
            if( len > 2 && iobuf[len-1] == L'\n' && iobuf[len-2] == '\r')
                iobuf[wcslen(iobuf)-2] = 0;
            len = wcslen(iobuf);
            printf("(%d) \"%S\"\  ", len, iobuf);
            if( iobuf[0] == L'\r' )
                printf("Yes\n");
            else
                printf("No\n");
        }
        fclose(fp);

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

All you posted is a bunch of nonsense. See post #6 in this thread for example of FindFirstFile() etc. The only other thing you need is the function remove (click the link here) to delete the file. But then we have already told you all that.

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

I don't see much different about the task bar in Win7 and Vista or XP. One minor difference is that Win7 lets you easily pin any program you want to it. Other than that, it looks just like earlier versions.

And the start menu doesn't look any different either.

What I don't really like is those "libraries" I see in Windows Explorer.

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

I'm only 39 years old (see Jack Benny) with 30 years more experience.

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

Interesting that people believe the alleged separation of church and state exists. Are you unaware that when after the country was founded, a prayer was said at the opening of a Congressional session? When did this practice stop?

AFAIK it didn't stop.

If there is a separation, how do you explain this, this, and this? Hypocrisy?

See post #4 of this thread, but worth repeating anyway.

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

do you mean &say[i] ? in the loop at the bottom of the program?

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

Standard C function remove() will delete a file. If the folder contains other folders than its a little more complicated because the code will have to be recursive (function calling itself) to process all the sub-folders.

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

the \ character is a special character in c/c++ and has to be escaped, meaning you need two of them remove ("c:\\users\\asus\\new.docx");

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

You need to turn off UNICODE. Go to menu Project --> Properties (last item in the menu), Configuration Properties --> General. Then change "Character Set" (3d from bottom on the right) to "Not Set".

Either that or use UNICODE string literals, such as _TEXT("Some string literal")

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

Yes - it reminds me that we gave up immortality to have sex - worth it?

We are not giving up anything -- you can't give up something you never had in the first place. I'd choose sex anytime over immortality via cloning -- see Multiplicity

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

. There is a huge difference between a car that costs, thousands, in asking for a donation and something 16x+ cheaper.

Other than the dollar amount, there is no difference. You are not a non-profit organization, so people have no reason to give you the money, regardless of the amount.

What you need is a little creative thinking about how you can make money to get what you want. For example I read where someone sold lottery tickets, or raffled off something they already own. One man even raffled off his house. You would have to check out our state laws before doing that.

Another person started up her own web site and after awhile people started donating lots of money to help her keep the site going. A lot of people have built successful web businesses doing just that.

And if you are old enough you can always get a part-time job at McDonalds or some other fast-food place.

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

Well, these messages are obviously not so secret anymore...

But, IMO promotion of any single religion by any government is not right.

Agreed, but tell that to GB and all the mideast (Islam) nations.

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

What about the fact that there is no mention of a deity anywhere in the United States Constitution?

Exactly my point -- The constitution does not state that US government can not practice a religion.

Or the fact that Thomas Jefferson - author of the Declaration of Independence, founding father, and third President of these United States - coined the phrase in a letter written to Danbury Baptists, in which he referred to the First Amendment to the United States Constitution as creating a "wall of separation" between church and state.

Not relevant. TJ does not speak for the Constitution. That was only his opinion.

The United States Supreme Court also recognizes the separation of church and state. First in 1878, and then in a series of cases starting in 1947.

Yes there have been a lot of court cases about this, but not one of them said the Constitution required separation of church and state. Just one example:
Marsh v. Chambers

Facts of the Case:

Chambers was a member of the Nebraska state legislature who objected to its chaplaincy policy. The clergyman who opened each session with a prayer was paid by public funds. The District Court objected to the use of public money to pay the preacher�s salary while the Appellate Court objected to the prayer being offered.

Decision:

By a 6-3 vote the Supreme Court permitted the practice of beginning the legislative session with a prayer given by the publicly funded chaplain.

And …

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

getline() will return the entire line up to the '\n' character. That is not what you want. And the loop is wrong.

while( myfile >> words[a] )
   a++;

[edit]Well, the above is incorrect too because you are storing the words in a vector. Vectors do not auto expand when using indices as you posted so you need to use push_back() method to get that behavior.

std::vector< std::string > sWords;
std::string oneWord;
while( myfile >> oneWord )
    sWords.push_back(oneWord);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Will you all donate $30,000.00 USD to me so that I can buy a new Toyota Prius?? Just deposit all your money in my PayPal account. Its nice, shiny new car that will give me lots of pleasure to drive.

sergent commented: lol +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here and here are a couple links you might want to read

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

Trying to go to Vista from Win 7 makes no sense.

I think you have that reversed, but I agree that going from Win7 to Vista is a bad idea.

People get what they pay for -- installing pirated software will get you a lot more than what you bargained for.

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

Plus there is the whole 'separation of church and state' thing

There is no such thing as "separation of church and state". The US constitution just prevents the US government from passing certain kinds of laws concerning religion, it does not prevent it from practicing a religion. And the US government has passed a few laws governing religion, such as tax laws. Indeed -- religion is actually sanctioned by Office of the Chaplain, United States House of Representatives

To serve as Chaplain for the U.S. House of Representatives is truly an honor and a privilege.
<snip>
The formal prayer before each legislative session of Congress, and even before days of pro forma sessions, ...

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

Instead of const double& error = 0 you could code it as const double* error = NULL . References can not be NULL, but pointers can.

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

If you are taking a C course you should already have a textbook and notes from class lectures. C programming is not a course that you can study in one evening and expect to get a passing grade. It requires a tremendous amount of time and effort.

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

As i did in my first post, i meant by using recursive function calls.... when we call a function recursively , it will automatically push the local variables to stack right?

Wrong. The variables are already on the stack. The only thing pushed onto the stack is the return address of the calling function. On function entry the compiler will generate the code needed to reserve stack space for the function's local variables plus a few that the compiler itself might need for temporary storage.

in my case , to print in reverse order, i thought recursion would be suffiecient

It would probably work, but it won't be the most efficient in either speed or memory (stack) requirements. The most efficient method is to use a loop without recursion.

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

>>what actually makes the first one [( ie) use of pointers in classes] advantageous rather the second one ??

Nothing. The two examples you posted the first one (ignoring the error in the code) is actually less advantagous, not more advantagous because the pointer is unnecessary because there is a global object that should be used.

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

There was some talk awhile back about disabling signatures for new posters in order to reduce signature spammers. Apparently Dani has implemented that because all the older posters here have signatures.

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

its still giving error i want to display month name in character

Post the error message.

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

>>my go-to book, C:ARM(C a reference manual) doesnt even have this function!
because getline() is not a standard C function. Its a standard c++ function, not C. If your compiler implements a C getline() function than ok, but don't expect to read about it in any text book.

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

C programs do not have the ability to push stuff on the stack like assembly language does with the push and pop instructions. So if you have something else in mind you need to explain it to me.

>>and are these functions standard??
Yes. all the functions in string.h are standard.

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

<deleted> what ^^^ said

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

what are the error messages?

>>cout <<"add"<<addBills(expense m1);
The parameters should not contain the dta type, just variable names, such as cout <<"add"<<addBills(m1);

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

<deleted -- duplicate post>

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

strstr() is not a function that would be useful for this purpose. I would use strtok() to split the string into individual words, put each word in an array of char pointers, then print the array backwards from highest to lowest array indices.

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

I really really HATE two things about your code style: (1) CAPITALIZING FUNCTION NAMES, and (2) typedef'ing standard c++ class names. All that accomplishes is making your program more difficult to read and understand. You should be coding for clarity, not attempting to impress your teacher or others with an obnoxious coding style.

mrnutty commented: I really really hate that too +3
jonsca commented: I wasn't gonna say anything... hehe. I figured OP missed FORTRAN since he had a READ method (no WRITE(*,*) though) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Read this article about how to pass strings between VB and c++

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

>>(unsigned int)strlen(cmd)

The typecase is not necessary because strlen() returns unsigned int.

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

I know in C++ the STL has a function for comparing strings, dont know about C.

strcmp() is a case-sensitive string comparison. Some compilers implement a case-insensitive comparison such as stricmp()

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

My guess is that VALUES strings must be surrounded with single-tick quotes (unshifted double quotes on my keyboard). sprintf(cmd, "INSERT INTO prueba VALUES('%s')", Name);

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

>>this is the question and i want functions for the highlighted.
Well, you're not going to get it here. You will have to write the function yourself.

How to sort the names will depend on how you have the names stored in memory. There are lots of sort algorithms, but the easiest to code is the bubble sort. You will need to write two different sort algorithms, one that sorts the strings and the other that sorts the integers.

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

There is no such class or structure named wxNoteBook.

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

Is there anything to share here?

Nope -- that's why I deleted it. I deleted it because I answered post #40 before discovering it had already been answered.

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

You will want to use _beginthreadex() to create the two threads. Scroll down to the bottom of that link and it will show you an example of how to create the thread and wait for the thread to exit. After the thread ends call GetExitCodeThread() to get its return value. Those functions are declared in <process.h> and <windows.h>

The program instructions also state that you have to pass several variables to those threads. The only way you can do that is to create structures to hold the values and pass a pointer to the structure instance as the parameter to _beginthreadex().

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

Depending on the operating system, argv[0] may contain the full path to the program. It does that when run under MS-Windows, but may not when run under other operating systems.