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

Sorry, but killing someone is never funny or humorous, except maybe in a cartoon like RoadRunner where the person or other living creature is not really killed.

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

Unless you are told to do otherwise you don't swap the entire nodes when sorting the list, just swap the data so that the pointers remain unchanged. Some instructors won't let you get away with it that easy though, so you need to ask him/her.

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

what is ctt?

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

build failed because you didn't write code for function disp_student_classhonour() (or you didn't post it)

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

A quick glance at the code indicates whoever wrote it didn't know what he/she was doing. For example lines 28-35 are writing beyond the boundries of the array. Line 25 declares undefined return value for main() -- the only legal value is int, never void. I'm not going to bother reading the rest of that mess.

whats the use of strcpy??

If you don't know what strcpy() does then you shouldn't be attempting to make sense of that code. google for "strcpy" and you will find the answer to your question.

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

But could anyone please help me with how to convert these char arrays into integer arrays.

No conversion is necessary, characers are nothing more than small one-byte integers with a range of values -127 to 126 or unsigned 0 to 255. You simply treat then as if they were int arrays.

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

i think shanki himanshu has a great solution.

Then give him some rep to show your appreciation :)

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

Sorry Walt, but that won't work. The range of numbers is 0 to 10^9, which requires an array 10,000,000,000 elements.

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

Xor all the numbers as you input them. at the end you will left with the number occurs once.

Can you elaborate on that? A couple examples please?

I_m_rude commented: first time, god of C asking a question :D +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't know if this is the "most efficient" way, but one way to do it is to have an array of integers, then fill the array with numbers as they are read from the file. When you find a number that appears a second time delete it from the array. When done check the array for undeleted numbers. To delete a number just make it -1 since that is not a valid number is your data file.

Another possibility is to create a linked-list of the numbers, add a node when a number is read from the file that is not in the list, and delete the node when the number is read from the file that is already in the list. When done, the linked list should contain only one node. This will probably run a lot slower the the previous suggestion.

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

i need to know just how to read t text file that contain numbers line by line

I posted an example. You don't really need to know line by line, just read the numbers in a loop with fscanf(). I showed you how to read the first two lines of the file. From there on it should be fairly simple to create loops for nAnimals and nRacks.

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

Drinking and coding is OK, as long as your blood alcohol content is below 0.08.

Mine is never that low when I drink alcohol.

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

delete lines 14 and 26, the continhue statement is not needed

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

It might be easier to use fscanf() rather than fgets()

float dollars = 0.0F;
int nAnimals, nRacks;
fscanf(in,"%f", &dollars);
fscanf(in,"%d%d", &nAnimals,nRacks);
// etc etc

As for the rest of the problem, I'd first sit down with and figure it all out by hand with pencil & paper so that you will find out how to proceed programming it. The instructions seem a little confusing to me, maybe because they were translated into English from some other language??? Example: what is a "rack"?

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

In your example ob must be an int. For ob++ the ob int is evaluated first, then when that is done it calls the ++ operator (either the default c++ operator or the one in your program that you wrote).

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

I smoke because I heard it makes your code run 10% faster. It also makes any GUI you design look cooler.

I always thought drinking beer did that :)

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

The ++ operator doesn't know the difference, the compiler determines the difference based on where the ++ operator is used, such as ++i or i++. And in some cases it won't matter whether its post or prefix. The code inside the operator function should not care one way or the other.

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

what compiler are you using? Try debugging it (single-step through the program until you find the line that produces the error). Many good IDEs will have debuggers that let you do that. Check for uninitialized pointers.

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

What was you expecting time_t to contain? If struct tm is correct then the value for time_t is also probably correct. Recall from our previous discussion in this thread that time() returns time_t that is the number of seconds since some pre-determined date, quite often 1 Jan 1970, but that date can be anything the compiler wants it to be.

If that's not what you are wanting, then you could calculate it yourself by setting it to the number of seconds since midnight of the current day. Just convert HH and MM to seconds. The problem with that approach is that it makes it pretty difficult to find the difference between two times because the two times may or may not be on different dates.

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

whish granted, but the pirates capture and torture you for a year.
I wish I could eat anything I wanted without gaining weight.

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

Can we make it "17:30" now

If you want the time_t converted back to a string then call strftime() to create the string, which works a little bit like printf()

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

use assert() instead of TRACE. Or create a console project that supports MFC.

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

wav files reside on disk, so you read it from disk (don't know what wrote it)

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

It might also depend on which operating system the wav file was originally written with -- such as Big or Little Endian

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

Check out some of these Microsoft links. As they say, practice makes perfect, so you should plan to spend a lot of time creating projects, exploring the various options available in the IDE, and learning to use the excellent debugging facilities. And don't forget that you can always ask questions here at DaniWeb about things you don't understand.

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

Nice work Samarium resurrecting a 5-year-old thread that nobody cares about any more.

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

The way to make the concept work is to use an array instead of individual variable names. If the program already has individual variable names then to use a loop you could create an array of pointers that point to each of the individual variables, something like this:

char a1[]="ok";
char a2[]="yes";
char a3[]="right";
char* names[] = {a1,a2,a3,NULL};
for (int n = 0; names[n] != NULL;n++;)
    cout << names[n] << '\n';
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you also need to set a year/month/day because time_t is the number of seconds since 1 Jan 1970 to the specified date.

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

I call mktime(). One crevet -- you need to initialize all fields of struct tm to 0 before using it becuse mktime() will return an error of any of the fields contain random junk values. Here's an easy/quick way to do that.

struct tm tm;
memset(&tm,0,sizeof(struct tm));
WaltP commented: A crucible or melting pot? Or did you mean caveat? ;o) +14
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

computer science is compatable with almost all other fields, and at least some knowledge of other fields is required because programmers and computer scientists don't work/live in a vacuum. To answer your question, yes I can see a double major of computer science and mechanical engineering.

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

I wasn't really suggesting you go back to BBCode, but simulating their code tags. [code][/code] can never be confused with 4 spaces in normal text. If you parser sees "[code]" then it should know it's code, but when it sees 4 spaces your parser doesn't know whether its normal text or code.

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

It was much simpler and safer to just use CODE tags. That way your algorithm wouldn't have to guess about what is or is not code, and sometimes it guesses wrong.

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

you don't need that second loop

for(int i = 0; i < 3; i++)
   cout << a[i] << '\n';
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

are those hex values? Are you certain there is a comma between words? e.x. 0010 and 0440? One way to do it if with int ival; fscanf(%x", &ival);

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

you could compress them with a program like WinZip then require a password before de-compressing them.

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

i need to download a good compiler, what can you recommend me?

Download free VC++ 2010 Express or newer -- vc++ 2012 will be released when Windows 8 is released, but you can get prerelease version now for free.

You might also try Code::Blocks with MinGW. Dev-C++ doesn't work most likely because it hzas an old version of gcc compiler. CB is a better IDE and has current version of gcc.

std::string url = ("http://site.com/dir/%i", id)

That is c++, not c. C does not support std:string class

json parsers
I know nothing about it.

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

Do you mean the edit control? If you need to edit a label control then just change its Text property.

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

is ipconfig supported in *nix? Easy way to find out, just try it from a terminal.

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

Where have you searched? Have you studied the information in this link?

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

Is the data in ascending sorted order? If not then the program can't work.

why does the loop counter i start at 1 instead of 0?

ksz[i]=KSz[0];

Don't name your arrays like that because you will do nothing more than confuse yourself (and others) when read later. name kSz something else and make the name meaningful for what data it represents.

for(j=0;j<=18;j++)

That is reaching beyond the bounds of the array. The array only has 16 elsmenets, not 19. The loop counter should be: for(j=0;j<14;j++) (14 because of the j+1 in the next statement)

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

If I were asked to show how to implement malloc/free in a job interview I think I would laugh, and tell them to find some other fool to work for them!

Although the question has little practical purposes, the reason for an employer to ask such a question is to find out how much the interviewee really knows. A lot of people go to interview and do a lot of bloating without knowing very much. Such a question as this will help weed out the chaff from the wheat. If you want the job then you would show off your great programming skills and write the program that they asked.

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

doesn't your book have questions at the end of chapters?

Question: Easy: write a linked list of random integers that always keeps the data in sorted order.

Harder: Same as above but add ability to add additional numbers, delete a node, or modify an existing node (might have to mode the node to a different position in so that its in sorted order).

Write the linked list to a data file so that it can be read back when the program starts.

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

Maybe a different color, or neon blinking lights saying "<<< Link here" :) Dani removed the post numbers some time ago because she thought they were confusing if another post referred to the number and the original post was later deleted. But that doesn't happen very often, maybe once in 10,000 posts???

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

The time posted for each post is actually a link to the post's permanent URL

Maybe you need to make that feature more obvious.

I still don't understand what you want me to elaborate on. I thought what I posted was pretty clear.

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

VC++ defaults to using precompiled headers, which means that it will preprocess all the header files once and use that preprocessed file for all the *.cpp files in the project. stdafx.h is the header file which contains all the other include files that are usd for this purpose. So the first thing that must appear in all *.cpp files of the project is stdafx.h. If a *.cpp file need other includes they must appear after stdafx.h. This might seem a little complicated, but for large projects it can greatly speed up compiling all those *.cpp files. You have the option to turn off precompiled header files if you want to either when you create the project or later by changing one of the project properties. Once you turn precompiled headers off you can delete and remove from the project stdafx.h and stdafx.cpp if you want to.

_tmain and TCHAR are actually macros which allow your program to be easily compiled for UNICODE or not. VC++ defaults to UNICODE, which affects all the strings in the program. You can turn that off in one of the project properties. UNICODE is a computer standard way to represent languages whose alphabet requires multiple bytes of memory. For example each letter of the English alphabet consumes one byte of memory, but in Chinese a letter might need several bytes because they are graphic characters. If you want your program to be in Engligh only (or one of the other western languages) then …

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

I thought that was a requirement imposed by the assignment.

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

As someone who knows very little of conio.h, could you explain how cprintf, cscanf, cgets, cputs etc. behave differently than the standard functions of the same name minus the "c" at the beginning?

They were written by Borland Turbo C compiler for MS-DOS Version 6.X or earlier and used DOS interrupts that read/write directly to/from keyboard and screen memory. The only really useful function in it was kbhit() which allows you to check the keyboard memory to see if there is anything in it. Standard C functions don't have anything similar.

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

I didn't see any such restriction mentioned in the thread,

Since we don't have post numbers anymore I can't just give you a link to it but the op was given a large char array and asked to write his own malloc() and free() functions. I miss those post numbers alot because they were really handy in this kind of situations.

Could you elaborate on what you meant by the quoted statement?

Huh? What quoted statement?

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

The restriction is you can't use malloc() or anything like it, such as HeapAlloc() and AFAIK that is MS-Windows-specific function.

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

Please tell me if my code is correct

Compile your program for DEBUG and you can find out for yourself if it is correct or not. assert() does nothing if the program is compiled for release. How to do that will depend on the compiler you are using.