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

You need a compiler. What operating system are you using? If MS-Windows then download and install either Code::Blocks with MinGW or VC++ 2010 Express, both are free. If *nix then you probably already have the compiler named gcc. But you need to tell us about your computer and operating system before we can provide more details.

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

I meant something like this. Next question is how is the file formatted? Post a couple examples of the lines.

    count = 0;
    while(getline(filePath,line)) {
        bookTitle[count] = line;
        count++;
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 86 and 89 are the problem. You need to use a counter that counts the number of times getline() is called so that you can put the data in the appropriate item of the arrzy. Start the counter at 0 and increment it at the end of that read loop.

Ditto for lines 108 and 110

I see you already have a variable named count -- just use that, don't forget to reset it back to 0 before each of those two loops.

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

If you declare the array like that: char* command[25]. Otherwise you can do his: conrol(int n, char** command). Note: variable names are NOT usually in UPPER CASE.

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

char command[] is just a simple array of characters, or a single string such as "Hello". You can't store multiple strings all at the same time in it.

char* command[] is an array of pointers to strings, which is what you need for your program. Another way to express it is char** command.

All older compiler require a constant integer to expres the number of elments in array, such as char* command[20]. The newest C standard also allows it to be a variable, such as char* command[argv]. You might have to test it to find out which form your compiler supports. Which ever way your compiler accepts you have to be consistent throught the program, don't use char** command in one place then char* command[] in another because the compiler will complain about that too.

If you are still confused about pointers then maybe you should study this tutorial.

piero.costa commented: perfect awnser! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

char command[argc]

You need to make that an array of pointers: char* command[argc], then before copying the string from argv you will have to call malloc() to allocate memory for each string + 1 for the string's null terminator.

line 8: The for statement is incorrect format. --

char* command[argc];  // older compiles won't like this line
char**command = malloc(argc, sizeof(char*)); // alternate way to do it
for(i = 1; i < argc; ++i) 
{ 
   command[i-1] = malloc(strlen(argv[i])+1);
   strcpy(command[i-1], argv[i]); 
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are just using the same font for all the edit boxes. If you want each one to have a different font then you need to create a font for each one. Make m_font an array and create separate fonts for each edit control.

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

Have you tried this?

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

what operating system? MS-Windows look for WinSock, *nix look for Burkeley Sockets. There are lots of free online tutorials, even a couple youtube videos.

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

get vc++ 2010 express -- its free, so is Code::Blocks/MinGW compiler. Or, download an install SP6 for your compiler from Microsoft web site. I don't know if its still available though.

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

what compiler are you using? I know Visual Studio 6.0 had a bug that did that but it was fixed with one of its patches. Write another tiny program just to test if your compiler has a similar problem.

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

just H:\\* (that's five \ characters with no spaces) The 5th \ is to escape the * so that markup doesn't use * for other purposes while editing.

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

Check here

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

Similar to the redneck vasectomy (light the fuse and count to 15).

or redneck sex change operation :)

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

How about if poster wants white space untouched then just use &nbsp; but that would have to be an exception to your rule of no html. How is it done when Code ? Shouldn't inline code behave the same?

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

I wanted to see if there was a work-around, but I guess not.

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

According to this html should display &nbsp; as a space

Test: "&nbsp;&nbsp;&nbsp;&nbsp;"

Test failed.

Therefore, DaniWeb-flavored Markdown currently does not allow any HTML. Both HTML tags and entities will not be parsed.

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

I want to post ' ' with 4 spaces between the tick marks, but the markup languages removes them. I tried inline code but that didn't help. How can I do that without using the Code button?

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

while (player[0] == ' ' || player[0] == ' ')

There is no such character as ' ' (four spaces between ticks), that is three or four characters, not one, and must be surrounded in double quotes, such as " ". Even that is wrong becsuse player[0] is a single character.

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

Here's what I get when I enter a player's name (you need to explain in the question that you are looking for a number), and flush the input stream if input is wrong.

re-enter them: You must enter numbers from 1 to 3, please re-enter them: You mus
t enter numbers from 1 to 3, please re-enter them: You must enter numbers from 1
to 3, please re-enter them: You must enter numbers from 1 to 3, please re-enter
them: You must enter numbers from 1 to 3, please re-enter them: You must enter
numbers from 1 to 3, please re-enter them: You must enter numbers from 1 to 3, p
lease re-enter them: You must enter numbers from 1 to 3, please re-enter them: Y
ou must enter numbers from 1 to 3, please re-enter them: You must enter numbers
from 1 to 3, please re-enter them: You must enter numbers from 1 to 3, please re
-enter them: You must enter numbers from 1 to 3, please re-enter them: You must
enter numbers from 1 to 3, please re-enter them: You must enter numbers from 1 t
o 3, please re-enter them: You must enter numbers from 1 to 3, please re-enter t
hem: You must enter numbers from 1 to 3, please re-enter them: You must enter nu
mbers from 1 to 3, please re-enter them: You must enter numbers from 1 to 3, …

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

wish granted: Your boss rejected your proposal.....hahaha

LOL I don't have a boss :)

Wish granted -- you are now only live in comic books.

I wish I were an Olymbic swimming champion with 50 gold metals.

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

A 23 year-old man severly burned himself after igniting a firecracker in his butt cheeks (link).

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

You probably need to use a merge-sort algorithm. Read the file in small chuncks, sort them, then write each chunk into its own file. When that is done you might wind up with 10-15 files, depending on the size of each chunck read. After that, open all the files at once and begin merging them into the final destination file.

You can probably find a program that already does that.

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

what kind of algorithms do you want? There are millions of them.

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

void main()

main() ALWAYS returns an int, declaring it as void could result in undefined behavor, read this thread

lines 16 and 17. Most C compilers and C standard before C99 require all variable declarations at the very beginning of a function or other scoped block marked with { and }. To be compatible with C standards older than C99 you should declare them at the beginning of a block. This may be important if your instructor wants to compile your program and does not use the same compiler that you use.

memory allocations: instead of expanding the string buffer one byte at a time it is much more efficient to allocate the memory in larger blocks, allocating too much memory is ok because the incased efficiency offsets the wasted memory. Computers have so much RAM now days that it's not even worth the effort to allocate exact amounts of ram. Here is one way to do it

void foo()
{
   const int BLOCKSIZE = 16;
   char *string = NULL;
   int input;
   int current_size = 0;
   int index = 0;
   while( (input = getch()) != EOF )
   {
       // check if we need to increase the length of the string
       if( (index+1) >= current_size)
       {
           current_size += BLOCKSIZE;
           string = realloc(string,current_size);
       }
       string[index++] = input;
    }
}
teachMyself commented: Helped a lot. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

wish granted -- you get a computer with no motherboard, CPU, memory or hard drive.

I wish to go on vacation to Australia.

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

to give us guys something to play with.

what's blowing in the wind?

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

Please post the code you have written.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
  1. The array must be in sorted order, you can either enter the numbers that way or call some sort of sort function after input.

  2. Binary search assumes unique values, not duplicate values. The array can contain duplicates but binary search algorithm will find only one of them.

  3. Once one of the values are found the program needs to check other locations immediately before and after the location that was found. Sequential seareches are useful here because binary search can't do that.

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

I think its time for you to get a new one.

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

Be careful what you wish for, you might just get it.

Knowing all the science that will ever be known, was known, and known right now

Who would believe you? You would probably be put into a straight jacket and locked up in a padded cell for the rest of your life. People would say "he's crazier than a bed bug."

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

but, sir how they will work in a linked list ? how to break a linked list like we do in array ?

What do you mean by "they"?

I posted a complete example of bubble sort

[edit]Oops! I just realized this is C forum, my example was in C++. The sort algorithm (except swapping) would be the same in both examples.

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

Although unfortunately I am putting this program on a backburner, it seems that every time I add a new part to the program I hit a wall.

That's part of the learning process -- don't give up just because something is confusing, do some research and ask questions here at DaniWeb.

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

ave a problem in which i want to declare two pointers of undefined length....so i don't want to use malloc...

you have to use malloc() to allocate space in which to store the characters received from scanf(). If you don't want to use malloc then you have to declare the array as normal, such as char a[20]. However you want to do it the pointer you send to scanf() must point to valid memory large enough to hold all the characters you want to type at the keyboard. A better solution is to call fgets() so that you can limit keyboard input to a specific size.

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

write a function that returns true of false that indicates if one string is contained in another string. For example if "hello" is contained in "hello world". You can call that function as many times as you wish. If you have two strings "hello" and "world" call the function for each word to find out whether or not they are contained in a third string "hello world".

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

It's hard for everyone.

geojia commented: I wish c++ was the official American lingo +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Which flavor of BASIC will they use? The current one is VB.NET and the compiler is available for free at this link. Here is a brief introduction tutorial you can study

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

Start here

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

what computer language -- e.g. c++, c, vb, java, assembly, cobol, fortran, etc. etc.

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

I see you are compiling in UNICODE. Use wtoi() instead of atoi() See this link, or if you want your program to be portable between UNICODE and ascii you can use _tstoi() which is defined in tchar.h

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

can you restate that in English?

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

Maybe I misunderstand the problem, but if the first two numbers in the file are 9 and 8 then all you have to do is read x and y, then add them todether. There is no need for SUM array. Just delete lines 7 and 9.

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

use CString's GetBuffer() method, similar to std::string's c_str()

int x = atoi(s.GetBuffer());

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

Here is a free c++ ebook for beginners that I just found. I haven't read it, but it looks promising.

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

isn't merge sort is best for this ?

Depends on how much data you are talking about. For very small quantities almost any algorithm, including bubble sort, will do. With larger quantites then bubble sort is not a good solution. There are lots of sort algorithms, Here is one of many threads that talks about sort comparisons.

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

Is there any built in function?

No. There are probably image libraries that you can get, some free and others not free. I never tried to do that so I don't know.

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

Are you seriously trying to equate a hunting knife or baseball bat with a .233 semi-automatic AR-15 rifle loaded with a 100 round clip?

The point was that there are many ways to kill someone, not just with guns. There is no point in banning guns because people will always find other ways to kill other people. I am in favor of banning certain kinds of guns but not all guns of all types. Here in USA it would not be possible to ban private gun ownership without a constitutional amendment, and the likelyhood of that happening is slim to none.

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

This is retaliation and vigilanty justice, and I would never consider that acceptable.

So, if someone raped and murdered your wife, you would do nothing? I doubt it. What do you think the US should have done about 9/11? Nothing. Not on a bet.

besides a vague statement of "treason is bad" which is not good enough to make up any kind of reasonable set of rules for dealing with disclosure of classified information

Treason can occur in other ways too, such as aiding the enemy. Jane Fonda did exactly that during Viet Nam in the 1960s. Many people considered her actions treason, but for some reason (maybe money??) she was never arrested for it.

Most states are divorced of any religious doctrines. Long story short, only in Islam do people still claim their religious law to be all good, and that it ought to be applied, verbatim, which is a horrifying thought, given the primitive and violent nature of those laws.

I think God that our Founding Fathers knew that truth also. That's exactly why US has a Bill of Rights, among them is the right to practice or not to practice any relegion we wish without government ineferrence.

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

there is death for all traitors as far as i know in every country.

US has death penalty for treason, but its rarely enforced. Most were sent to prison, some pardoned by the US President.

the United States Code at 18 U.S.C. § 2381 states "whoever, owing allegiance to the United States, levies war against them or adheres to their enemies, giving them aid and comfort within the United States or elsewhere, is guilty of treason and shall suffer death, or shall be imprisoned not less than five years and fined under this title but not less than $10,000; and shall be incapable of holding any office under the United States."

Here is a list (very short) of persons convicted for treason in USA.