Jishnu 160 Posting Pro

I've a code , but there is a part I didn't undestand it.

Can u help me to undestand it?

I am writing the part I didn't understand it by red color:

The red part sorts the integer array intArray and then prints the sorted contents... Anything more specific you want to know about the algorithm? Then google for "bubble sort".

Jishnu 160 Posting Pro

It doesn't appear as if you have tried to develop an algorithm of your own. I can't write the entire code for you but I can tell you this much. Use an ifstream object to take values from the file repeatedly. Then for moving to a specified location in the file you can use either the file-handling functions or their equivalent manipulators. Alternatively, use the read() function for reading data.

Jishnu 160 Posting Pro

i want to know whether the two problems are same or different

The problem is the same. Solutions are worked out in different manner.

Apart from this, I could not make out from your post what problem you are facing. Please mention if I've misunderstood something.

You said this:

i have a doubt regarding the permutations of a given string and permutations of first N natural numbers...

But afterwards, you didn't mention the doubt.

Jishnu 160 Posting Pro

sOperator gets its value using this statement.

sOperator = (String) arg;

If your problem is solved, mark this thread as solved by clicking on the link below the last post in this thread.

Jishnu 160 Posting Pro

Lists are harder to implement initially. But just compare sorting, searching, inserting an element, deleting an element etc. for both arrays and lists. You'd realise that lists are better. What is more, lists are dynamic.

Jishnu 160 Posting Pro

Your reply was more specific. I just gave an example...

And yes,

You can either sort the numbers stored in each structure or sort the nth elements all the structure variables.

This is a golden truth.

Thank you for the compliments :)

Jishnu 160 Posting Pro

Theres a code in it and the author has used structure.
But he has used a string and an integer in his structure and has created array of structures. 1000 is the size to be specific.

True. But, again how do you propose to sort such an arrangement? You see, it no longer remains a simple vector. It becomes a vector of structures. There is where the difference lies. In such a case, there are two ways, you can either sort the numbers stored in each structure or sort the nth elements all the structure variables.

Ah! Ancient Dragon and I again replied at about the same time...

Jishnu 160 Posting Pro

This is your first post. But, the next time you post your code, please use code tags so that the users can view the code along with proper alignment.

if (isFixReg)
    sText2 = (String) arg;
else 
    sText2 = text.getText() + arg;
text.setText(sText2);
isFixReg = false;

This indicates that if isFixReg is true, then no other operand (argument) is needed to be displayed (For eg when memory/clear buttons or operators are selected). If isFixReg is false, then another argument is to be added to the text being displayed.

For eg if you press 21, then when you press 2 then isFixReg is true and afterwards when you press 1 then isFixReg is false because it has to display the previous argument (which was 2) also to display '21' and not only '1'. I hope I'm clear.

Looks like darkagn and I replied at about the same time. I hadn't refreshed my page while typing my reply.

darkagn commented: nice explanation :) +1
Jishnu 160 Posting Pro

All I wants to do is sort the array in the structure using sort().

If your only purpose is to sort a vector, then why are you using a structure? By doing so, you are creating a vector of structures, wherein each structure consists of a 10-element array. How do you propose to sort numbers stored in such an arrangement?

Instead, try using simply an integer vector and then sorting. I tried it and got no errors with the compiler you've specified.

Jishnu 160 Posting Pro

You are surely not going to get anyone to write the entire code for you. You know how to do the task. Separate it into several small manageable modules. Write the algorithm in a logical order. Refering to each step in the algorithm, write the corresponding C language statements. After you've written the entire code, compile/run it. Try to debug the errors if any. If you are unable to do so, you will definitely get help from this forum. I don't see in what other way I can help you. Please mention if this is not what you were looking for. In that case you need to be more specific with the kind of help you want.

Ancient Dragon commented: Great advice :) +19
Jishnu 160 Posting Pro

You are right. Have you tried to code such functions? Please post them over here using code tags.

Jishnu 160 Posting Pro

Apart from the suggestions above, you can add features like multiplication, transpose, adjoint, inverse.... Matrices have a very wide range of applications. After doing these, you can add advanced features to solve some real-time problems like solving algebraic equations...

Jishnu 160 Posting Pro

You won't get any warnings if you add a break statement when the user chooses 0 (the exit option).

while(1)
{
    ...
    if(/*if user wants to quit*/)
    {
        break;
    }
}
Jishnu 160 Posting Pro

Hi there, eesti44! I'm also more of an electronics guy like you..

You can do that with hyperterminal or low-level programming using functions like inportb, outportb, etc... There are also some libraries related to port programming. Refer to some recent posts over here related to port programming.

If you would be more specific regarding your problem/project, then I'd be able to help you in a better way..

Jishnu 160 Posting Pro

Do you want to insert one more record to the file or do you want to modify the current values? In any case please mention how you've approached the problem uptil now.

Jishnu 160 Posting Pro

Please have a look at your textbook instead of asking such outright questions. Else google for it. Then, we would be happy to solve any conceptual doubt that you have regarding it.

Jishnu 160 Posting Pro

I can't see anything wrong in the function as such. Maybe something is wrong in the main() function where you are displaying the characters. Also, I think there should be || instead of && inside the condition of while loop. Do you mind posting the entire code?

Here is the void function to get the user input and write it to a file.

I don't see it writing anything to any file. It is just modifying the character array.

Jishnu 160 Posting Pro

do i have this in my program and if so where.

No. Looks like you've not yet come across the concept of functions. Try reading the chapter related to 'user defined functions' in your textbook.

Jishnu 160 Posting Pro

Hey, we appreciate your goodwill but this is not the way to do so. Go to 'contribute code' in the 'code snippets' section. Forums are meant only for problem solving.

Jishnu 160 Posting Pro

Okay, agreed. :)

Jishnu 160 Posting Pro

how i can use inportb() methord?

See in the help section. It needs the port id as the argument and returns the byte received at that port.

But, it would definitely be easier to use the libraries as jwenting suggested.

If your purpose is just to transmit or receive a file, use hyperterminal instead. It will do all the low-level stuff on its own.

this program cannot use in Microsoft visual c++

Specify the errors you encounter.

Don't use old style header files. And yes, void main() must be replaced by int main() ;).

Jishnu 160 Posting Pro

Looks like you are looking forward to interface LCD display (presuming that would serve the purpose of a scoreboard) using PIC microcontroller.

Please, in such projects, you need to be very very specific with the hardware connections that you've made. Also, specify the exact nature of the display you want (i.e. what you want to display when). After all, that would help us in helping you ;).

Jishnu 160 Posting Pro

i cant figure out how to print after each pass as shown above.

After each swap is done, use cout to display the values stored in the list at that particular juncture.

Jishnu 160 Posting Pro

The comment on top is the problem.

I didn't understand that.

Also, if you've no more problems, then mark the thread as solved.

Jishnu 160 Posting Pro

i tried several things BUT nothing works

Post atleast one such thing (code). We'll try to make it work.

Jishnu 160 Posting Pro

Maybe some problem with the access specifier keywords used for that particular function. Nothing else can explain such a behaviour. Atleast post your .h file so that it makes debugging easy.

Jishnu 160 Posting Pro

Try going for Go, Tic-tac-toe, Bingo... all of them with AI.. quite interesting and would take quite a time.

Jishnu 160 Posting Pro

It may mean the address of the bit/byte immediately beyond the address of the first bit/byte of memory used by the last item in the container, it may mean the first bit/byte of memory immediately after the block of memory used by the last item in the container, it may mean that there is a trailing node in the list/container that is automatically maintained by the list object, analagous to the this pointer. Who knows? It's only important if you're writing a class to extend/mimic the STL classes or are in discussions regarding changing the standards or are interested in the minutiae of the standards.

I am in total agreement. My query is solved. Thank you :).

No, they said the same thing in a different way.

No. vmanes said something that was very much different. Have a look at this.

back( ) returns the last object( the value )

He said that back() returns the object. But, back() returns the reference and not the value. Now that the problem is solved, it does not matter anymore.

Jishnu 160 Posting Pro

Inline functions are used to eliminate overheads which occur in case of calls made to normal functions. But it is a significant trade-off only when the function is restricted to 2-3 lines of code. Otherwise, the advantage is nullified by the large size of the code that is repeatedly pasted everytime the function is called.

Functions cannot be forced to be inline. They can only be suggested to be inline by using the keyword. It is for the compiler to decide whether to accede to the request ( in case the trade-off is advantageous).

Hope this helped. Google for more in-depth explanations..

Jishnu 160 Posting Pro

http://www.devx.com/tips/Tip/12583

Google for more stuff on similiar lines.

Jishnu 160 Posting Pro

By vmanes..

back( ) returns the last object( the value )

By vishesh..

No, back() return reference.

I'm confused. Both these members have said contradictory things. Someone please help me out.

Jishnu 160 Posting Pro

Okay. According to you, back() gives the value, not the reference. So, I'm understanding that this line

back() gives reference to the last element

given in the book is technically wrong. Thank you :)

Jishnu 160 Posting Pro

A peice of humble advice for elite1986.

You may have not known this before but it is considered (very truelly so) a malpractice and a cheap way to increase the no. of posts to post content in multiple posts. You can edit your post during the half an hour period after the time when you posted it. I learned this the harder way by losing my reputation. So I thought that I must inform you.

Ancient Dragon commented: Good advice. +19
iamthwee commented: How retarded! -2
Jishnu 160 Posting Pro

First is there a better way to do it than a series of bool functions?

No, I can't think of a better way. danzona has given an excellent peice of advice. Stick to it.

in determining all legal moves, and then assigning a random number, I run into some errors.

In doing these logically simple tasks, so you won't get any logical errors. You might get syntax errors, which if you post them here, we can help you out. Keep the good work going!!

Jishnu 160 Posting Pro

What is the difference between the back() and end() functions defined for list containers in STL?

It is specified in my book that back() gives reference to the last element while end() gives reference to the end of the list. I'm unable to understand how the two functions differ.

Jishnu 160 Posting Pro

The code is a mix of C and C++ as suggested by usage of iostream and stdio.h in the first place.

Secondly, I guess learning C++ would be easy as compared to converting such a code to pure C ;).

Jishnu 160 Posting Pro

a.out

What is that?

Use code tags & re-post the code along with the errors you are getting..

Jishnu 160 Posting Pro

i want to define a function that calculates the " integral" of a function

Not an easy job to define that for any given input function if you are a newbie..

Jishnu 160 Posting Pro

A peice of humble advice for devilofangel

You may have not known this before but it is considered (very truelly so) a malpractice and a cheap way to increase the no. of posts to post content in multiple posts. I learned this the harder way by losing my reputation. So I thought that I must inform you.

Jishnu 160 Posting Pro

Did you see the watermark at the back of the edit window?

I can't see any watermark. Perhaps, you were suggesting him to include the error statements inside his post along with the line numbers.

Jishnu 160 Posting Pro

i am not sure how to do it in C

Look up in your book.

is it the same in Java?

There are minor differences between the break statements used inside switch-case in C and Java. Otherwise, it is similiar.

Jishnu 160 Posting Pro

I had a decent start with The Complete Reference: Java 2 by Herbert Schildt... But somewhere, Herb has some misconceptions. (As quoted by someone over here in one of my previous threads. Probably it was jwenting).. That apart, it is a good starting point, especially if you are having a transition from C++ to Java. It emphasizes on all the similiarities and dissimiliarities between the two.

Jishnu 160 Posting Pro

I don't want anybody else to steal it

That can happen even if you PM someone ;).

Anyways, I'd be glad to help.

Jishnu 160 Posting Pro

What about a program that is waiting specifically for a letter or number, you know, you press the number or letter and then it presents the next one to type in??

Hey friend, please present your problem clearly. Otherwise, how would we be able to help you??

Jishnu 160 Posting Pro

Welcome. Use code tags. Read this before posting.
http://www.daniweb.com/forums/thread78060.html

Jishnu 160 Posting Pro

How can I create a path?

Functions related to handling directories are predefined in a header file named dir.h. Try using them.

Jishnu 160 Posting Pro

Just state in the pseudocode that x=x+20 results in incrementing the value of x by 20. Nothing else would be required.

Jishnu 160 Posting Pro

I think you've not learnt the basics yet... First the value of LHS expression is evaluated and then it is assigned to the variable on RHS... So, first X+20 (50) is evaluated & then it (50) is assigned to X. The procedure simply results in incrementing the value of X by 20. Other values remain unchanged.

Jishnu 160 Posting Pro

Use code tags :D

the problem is that i want a series of integers and passes them one at a time to function even.

If you mean that you want to implement the same algorithm for a series of numbers, use arrays. If you want to pass them one at a time to the function, then put the function call inside a loop.

Jishnu 160 Posting Pro

do you really mean
(Toggle Plain Text)
namespace { int foobar( int i ) { return ++i ; } }namespace { int foobar( int i ) { return ++i ; } }
is c++, but if you place the same function in the global namespace, it suddenly stops being c++?

Okay, agreed. It is because of C++ that we know the concept of namespaces. But if we see the code posted, there is no need of specifying a global namespace. What you are saying is that using the concepts because they are known. What I'm saying is no advanced concepts are needed if the aim is just to solve this problem. No offense is meant :).