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

switches with multiple variables is no supported, just as you thought it might not be. But ... if you convert the rgb values into COLORREF value then you could use that in the switch statement.

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

At least two problems with your program.

  1. The space is not the only character that is considered white space. It also consists of tabs, back spaces, and returns '\n'. The safest way to check for all these is to use the macro isspace().
  2. You can not use fstream's >> operator to read white space because >> always skips white space. What you want is to use fstream's get() method which does uninterpreted reads, much like calling read() for a single character.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Quick question... How are you supposed to edit the test ?

That was one of the OP's questions in his original post.

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

>>Need an answer

The answer is to use google.

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

You where into Elvis and the Beatles you say. Pink Floyd started out in 1965 or so. They are a famous band and one of my favorites.

By 1965 I was well on my wan in US military and no longer a teenager. I hated the sound of the new hard rock and acid rock that was coming out -- and still hate it to this day. Give me back the era of the big bands of the 1940's and I'll be happy.

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

@GrimJack: I saw something like that picture on tv once -- Oh yes, it was on Star Trek NG.

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

Did you use g++ as the compiler on *nix with NetBeans IDE? If you did, then MinGW is the MS-Windows port of that *nix compiler. Even so, your program may need some tweaking in order to get it to compile with MinGW.

What windowing GUI engine did you use in your program? If you used something cross-platform like wxWidgets then you should have few problems porting to Windows.

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

Did you compile with the project that I posted?

This is the options I selected when I created the project

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

I just created a win32 console program and your code compiled without error. vc++ 2008 express compiler. My project is attached if you want to look at it.

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

>> int goodLinks[kWordL + 1][kLinksL];

That's the culprit that is causing stack overflow. Make it a pointer and allocate the memory with new.

You are also going to have lots of problems with concantinating ".txt" to the pointers such as filename cause those pointers were never allocated enough space to hold the additional text. Suggest you replace all those pointers with std::string to avoid those problems. For example

std::string fileName = "None";
	std::string dictionaryName = "None";
	std::string sequenceFileName;
	string lastFileName = "None";

When you do that you will also have to change the function parameters to use std::string. Well, you really don't HAVE to do that but it would make your program a lot safer. Other changes will be needed too.

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

Don't know yet because I need a clean compile.

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

There are lots of these

1>c:\dvlp\test10\test10\test10.cpp(659) : warning C4258: 'i' : definition from the for loop is ignored; the definition from the enclosing scope is used
1> c:\dvlp\test10\test10\utils.cpp(646) : definition of 'i' ignored

Although they are warnings you need to correct the problems because they are actual errors. It is trying to tell you what you have attempted to use the value of a loop counter that was declared inside a for loop, which is not legal in c++.

for(int i = 0; <snipped> )

if( i == something) // illegal because i was declared above
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>A bump to defend gets()? - Dave Sinkula
Dave: Just what in the hell makes you think I was defending gets()??? I just don't understand all the negative reps I got for my post.

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

>>int __cdecl main(void)
Remove __cdecl because it isn't needed. The compiler will generate the correct code without it. The c and c++ standards do not allow other kinds of function declarations.

Don't know the answer to your question. Are you trying to compile that code as a C++/CLR project? If yes, then I think you created the wrong project type. Create a c++ console project.

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

Here is the correction to that insert function. Note that neither of the two loops you had work. In order to expand the array you have to start from the end of the array and work forward, decrementing the loop counter along the way.

Also you need to add some code that verifies that you don't attempt to insert more names then the array can hold. You have hardcoded the array size as 30, so you need to produce an error message if you attempt to insert a 31st name. There are better ways to do it so that you can enter as many names as you wish. One way is to allocate the number of pointers so that they can be expended when and if needed. Another way is to use a linked list, but you may or may not know that yet. A third way is to use either c++ <vector> or <list> class, but you many not know that yet either.

void doInsert(Listtype &list)
	//precondition: list has only the list from file data.txt
	//postcondtion: list is filled with user data and appended by adding a new list at a position specified by user
{
	system("cls");
	
	char firstname[30];
	char lastname[30];
	int age=0;
	int	pos=0;

	
	cout<<"input first\n";
	cin>>firstname;
	cout<<"last\n";
	cin>>lastname;
	cout<<"age\n";
	cin>>age;
	cout<<"pos\n";
	cin>>pos;
	list.size++;
	
	
    for(int i = list.size; i > pos; i-- )
	{
		
		list.person[i]=list.person[i-1];
		
	}	

	list.person[pos]=new Listnode;
	strcpy(list.person[pos]->firstname,firstname);
	strcpy(list.person[pos]->lastname,lastname);
	list.person[pos]->age=age;
	
		
	cin.ignore();
	cin.ignore();

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

I thought this website was for helping people I have not gotten a single help. I have been going over and over on this code and no help

It is for helping you. I just got home from work is why I have not tried to help you more.

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

Probably not. Just create a new project in builder then add the files from vs into it. I have not used builder for quite a few years to I don't know the current compiler.

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

what version of vs are you using? I tried to compile that *.cpp file using VC++ 2008 Express and get lots of errors. There have been lots of changes between vc++ 6.0 and 2008, so you might want to compile it with 2008.

Also, please post randomc.h

lukebradford commented: Thanks for the help! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Dani needs to replace her picture on that link -- its terrible.

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

you might want to get a copy of edlin line editor and see how it worked.

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

lines 171-176: what's the purpose of that loop? Just delete it.

GSPprog commented: no help +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No. But you could open a socket to another computer and ask it what time it is. Read this link

Salem commented: Nice +19
jonsca commented: What if the other PC isn't wearing a watch? +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Can anyone help?
Probably. But you are just wasting everyone's time if you don't post the code you have tried. We are not mind readers.

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

>>Thus, if the user selects (4) from the menu once, then again selects (4), the information will be printed twice the second time.

The reason is that the linked list is not destroyed between calls to menu item (4). Thus, when that function is called again it simply appends all the records in the file to the end of the current linked list.

The fix for that is to make sure the linked list is destroyed at the beginning of LoadDatabase() function.

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

since the result of line 12 sets variable compare to either true or false, then I would think you would want the result of line 8 to be similar, e.g. compare = stricmp(this.item, item) < 0;

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

Yes -- I was into Elvis, The Beatles, and others like them during my teenage years. We actually touched bodies when we danced.

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

I agree -- when splitting a hijacked post the mods are adding hijack to the new thread's title. Makes it easy to know why the first post in the new thread might be a little confusing.

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

If you don't need to print out the actual permutations, then you can
just calculate the number of different permutation.
Maybe something like this would work :

return  pow(2.0 , double( strlen(str) ) ) - 1;

I don't think so. In "ccccc" there are only 5, but your formula would product (2^5)-1 = 31.

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

Pink Who???

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

>

A wise man welcomes competition and betters himself, a fool stomps it out so his mediocrity shines.

You should have told that to Bill Gates & Microsoft :)

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

<deleted>

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

Yes, do the same thing for date. There is another way to write that function to avoid the static declaration of the buffer.

const char* gettime(char *inputbuf)
{
   // other code here
    return inputbuf;
}

You could also use strftime() but I never use that function because doing it myself is just as easy.

Look at struct tm in time.h and you will see the names of the date and time members.

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

first off, function create() is generating nodes that are never used. Let main() pass a pointer to the head of the linked list and let create() malloc it.

void create( node** head)
{
    node* newnode = malloc(sizeof(node));
    newnode->next = NULL;
    if(*head == NULL)
          *head = node;
    else
    {
          // find the tail of the linked list
           node* n = *head;
           while( n->next != NULL)
               n = n->next;
           // insert new node at the tail of the list
           n->next = newnode;
   }
}

int main()
{
    node* head = NULL;
    create( &head );
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you mean something like this:

const char* gettime()
{
    static char curtime[20];
    time_t now = time(0);
    struct tm* tm = localtime(&now);
    sprintf(curtime,"%02d:%02d:%02d",
          tm->tm_hour, tm->tm_min, tm->tm_sec);
    return curtime;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

scanf() is an evil function because it may not process all the keys in the input keyboard buffer(). It can not be used to get strings that contain spaces, such as most addresses, because "%s" stops at the first space. Replace all instances of scanf() with fgets(). For integer input, e.g. "%d" or "%i", use fgets() with character buffer then convert it to integer.

Here is another discussion of that topic within the past week on this board. You might want to read it.

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

@nerdinator: have you gone through the Microsoft Scribble tutorial? It will show you many things about MFC, including how to read/write the files.

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

Depends. Does your application have a File-->Save and File-->Open menus? Then put that code in the event handlers for those two functions.

Otherwise you could put the read code in OnNewDocument() and the save code when the application exists.

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

The first TV I bought that had a remote control I could change channels by jingling my car keys.

I also remember TVs that had round screens, and pictures were only in black & white. Then when color was becoming popular each program shown in color would be advertised as "Brought to you in living color!" and a peacock tail feathers.

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

VC++ 2008 has some problems with viewing the values of variables, I think it gets confused sometimes.

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

for dynamic string allocation while using the string use the C++ CString class

There is no such standard c++ class. You are either thinking of std::string, which I already mentioned in my post, or MFC CString class, which only works with Microsoft compilers and MFC.

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

Well, it does open the file, it just doesn't do anything with it. If you want the file to be displayed on the screen then you have to add more code to read and print it.

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

what do you mean by "still not working"? What doesn't work ? All your program does is open a file if the user enters 1 to the prompt. So how do you know the program isn't doing that?

line 42: What's the purpose of that line? There is no cin so the user can not enter either 1 or 2 for that line.

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

Oh yes, I see that variable. But it is initialized with the wrong value. Should be int a = '1'; meaning that '1' is not the same thing as 1.

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

No, I do not create movies.

You mean "yes" I do not create movies. When you say "no I do not", that means you do -- two negatives make a positive :)

"Yes, we have no banannas .."

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

How many people have made the golden 1000 anyway? Would it really bring DW to its knees if every one of them started a yipee thread? I don't know.

*Sheesh* some people...

There have been quite a few members, but I don't know how to get a list of members and their post count any more. At one time there was a quick link to that information, but that has been removed. But there certainly isn't enough to bring DW to its knees.

I see nothing wrong with this kind of thread -- its helpful to recognize those who have made exceptional contributions, and this is just one of them.

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

My dream computer would be a hologram that computes in the future and returns the results to the present, like in Star Trek Next Generation.

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

>>Is this a 64 bit issue? Im on a x64 project..

Not if you are compiling with a 32-bit compiler. It's the compiler, not the os, that determines 32 or 64-bit programs. But I doubt that is the case. Post some code that demonstrates the problem.

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

Do you mean std::string? Yes, then use its find() method. If you mean character array then use standrd C function strstr() which is declared in string.h (or cstring for c++ programs)

Of course you may not be allowed to use either of those if your instructor wants you to write your own function.

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

move lines 34 and 40 up near he top of main() so that the rest of your program can access those two stream objects. The two open statements are correct.

line 33: wrong comparison. If the user must enter either 1 or 2 then line 33 comparison should be if( d == '1' )