C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C++ Expert!

Join 307,137 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,834 people online right now. Registration is fast and FREE... Join Now!




Data Structures In C++ Tutorial

3 Pages V < 1 2 3 >  
Reply to this topicStart new topic

> Data Structures In C++ Tutorial, Writing Data Structures using OOP in C++

Rating  4
theU
*



post 23 Sep, 2007 - 08:49 AM
Post #21
Just out of curiousity ( because I'm new to all this) is "endl" the same as '\n'; ????

Please clarify. Thanx
Go to the top of the page
+Quote Post

Bench
Group Icon



post 23 Sep, 2007 - 09:04 AM
Post #22
QUOTE(theU @ 23 Sep, 2007 - 05:49 PM) *

Just out of curiousity ( because I'm new to all this) is "endl" the same as '\n'; ????

Please clarify. Thanx


in C++, cout << endl; is the equivalent of..

CODE
  cout << '\n';
  cout.flush();


For your purposes, you probably don't really care about the call to .flush() ... so feel free to use '\n' if you prefer.
Go to the top of the page
+Quote Post

hir_sus_jp
*



post 10 Oct, 2007 - 04:44 AM
Post #23
I'm learning many things from this tutorial. Thanks, born2c0de.
Go to the top of the page
+Quote Post

hir_sus_jp
*



post 26 Oct, 2007 - 01:30 AM
Post #24
I prefer endl to \n. When a program is working properly, it doesn’t matter which one you use. But when a program crashes, \n might mislead you. If there are any un-flushed data in the buffer when a program crashes, the un-flushed data can’t make it to the screen, or whatever destination. So what you see on the screen is not the actual output the program has written. You don't want to debug the code with the partial output.

This post has been edited by hir_sus_jp: 26 Oct, 2007 - 11:39 PM
Go to the top of the page
+Quote Post

tody4me
*****



post 18 Jan, 2008 - 10:12 AM
Post #25
Very well documented tutorial. Once upon a time I wrote code in C++ and have been wanting to get back to it, but needed an understanding of how to store data properly before I picked it up again. I especially loved the in depth instructions for the Binary Search Tree, as I had only gotten to Linked Lists previously and always wondered exactly how they worked.

This post has been edited by tody4me: 18 Jan, 2008 - 10:12 AM
Go to the top of the page
+Quote Post

born2c0de
Group Icon



post 20 Jan, 2008 - 07:53 AM
Post #26
I'm glad you liked it smile.gif

I'll be writing a sequel soon in which I plan to include more complex data structures (and their operations) as well so be sure to check the Tutorials section for updates.
Go to the top of the page
+Quote Post

kamalharbi
*



post 21 Feb, 2008 - 05:16 AM
Post #27
Real it's great to find like this site in the world
Really amazing
Thanks for helpfulness
Kamal Harbi
Go to the top of the page
+Quote Post

cold-blood
*



post 18 Jul, 2008 - 04:09 AM
Post #28
hi! thank you for your tutorial,.. it's a big help.. but can you help me on my project? It's about banking transaction system.. that keypad 1=open new account, 2=deposits, 3=withdraw, and 4 = close account.. I can make only one account.. but my prof. need 5 accounts.. can you help me.. plzzz! smile.gif

This post has been edited by cold-blood: 18 Jul, 2008 - 04:12 AM
Go to the top of the page
+Quote Post

KYA
Group Icon



post 18 Jul, 2008 - 07:47 PM
Post #29
cold-blood please post in the appropriate forum for questions; it will help you get answers faster--also, show code you have done so far smile.gif
Go to the top of the page
+Quote Post

born2c0de
Group Icon



post 25 Jul, 2008 - 01:13 AM
Post #30
I've *finally* removed the entire tutorial from the code tags and formatted it to give it a much cleaner look.
tutorial.readability+=50;

Enjoy!
Go to the top of the page
+Quote Post

blacksnake
*



post 7 Oct, 2008 - 02:37 AM
Post #31
can you show the basics of expression trees?
Go to the top of the page
+Quote Post

casterden
*



post 22 Oct, 2008 - 09:05 AM
Post #32
/*BINARY SEARCH PROGRAM BY SUMAIR IRSHAD*/
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int arr[]={1,3,5,7,9,11,13,15,17,19};
int i,target,start=0,end=10,mid;
printf("enter target");
scanf("%d",&target);
while(target!=arr[mid])
{
mid=(start+end)/2;
if(target==arr[mid])
{
break;
}
else if(target<arr[mid])
{
end=mid-1;
}

else if(target>arr[mid])
{
start=mid+1;
}
}
printf("target found at %dth location",mid+1);
getch();
}
Go to the top of the page
+Quote Post

bonnie1702
*



post 30 Oct, 2008 - 01:23 AM
Post #33
Hey there!

I'm new to c++ and new to this forum. I find the data structure tutorial very easy to read and understand. I haven't yet tried all the code yet. but I did do the one for stack (push and pop) and when I compiled, I got the error:

37 C:\c++Stuff\Stack.cpp [Warning] converting to non-pointer type `int' from NULL

I am using bloodshed's dev c++, so I thought I'd let you know that is whats happening. So if there is an error somewhere it would be nice to fix it. Does anyone else have any similar compilation errors with any of the code listed in the tutorial?

cheers
nm smile.gif
Go to the top of the page
+Quote Post

bonnie1702
*



post 31 Oct, 2008 - 12:59 AM
Post #34
Hi, back again!

I fixed up the minor error in the stack class by replacing the NULL with 0. Now it compiles and runs fine.

I have since tried the queue class and there are a couple of minor typos ie., ensure that tmp is actually spelt temp, and in the second for loop in the main method, you need to declare iter as int iter; if you dont want keep typing the data type for every for loop, just declare it as a global in the main, like such: int iter.

After fixing up those, I ran the program and did not get the same output as in the example. this is what i got instead:

QUOTE
Queue before adding elements:
2000215017 0

Addition number: 1 : 2000215017 0 32
Addition number: 2 : 2000215017 0 32 23
Addition number: 3 : 2000215017 0 32 23 45
Queue is Full
Addition number: 4 : 2000215017 0 32 23 45
Queue is Full
Addition number: 5 : 2000215017 0 32 23 45

Queue after adding elements 2000215017 0 32 23 45

Deletion number: 1 : 0 32 23 45
Deletion number: 2 : 32 23 45
Deletion number: 3 : 23 45
Deletion number: 4 : 45
Deletion number: 5 : Empty


so there you have it.

has anyone else had any problem with the example code?

cheers all
nm cool.gif
Go to the top of the page
+Quote Post

ali khan
*



post 12 Nov, 2008 - 10:07 PM
Post #35
QUOTE(born2c0de @ 17 Sep, 2006 - 01:12 AM) *

I'm glad to know it helped you.

i have a pproblem in the topic escape sequences is there any 1 to help me?????????????????????
Go to the top of the page
+Quote Post

naeem hassan
*



post 17 Nov, 2008 - 02:35 AM
Post #36
QUOTE(casterden @ 22 Oct, 2008 - 09:05 AM) *

/*BINARY SEARCH PROGRAM BY SUMAIR IRSHAD*/
#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int arr[]={1,3,5,7,9,11,13,15,17,19};
int i,target,start=0,end=10,mid;
printf("enter target");
scanf("%d",&target);
while(target!=arr[mid])
{
mid=(start+end)/2;
if(target==arr[mid])
{
break;
}
else if(target<arr[mid])
{
end=mid-1;
}

else if(target>arr[mid])
{
start=mid+1;
}
}
printf("target found at %dth location",mid+1);
getch();
}

Go to the top of the page
+Quote Post

bonnie1702
*



post 27 Nov, 2008 - 12:28 AM
Post #37
Would be good if you could add to your tutorial some stuff on double linked lists

regards
NM tongue.gif
Go to the top of the page
+Quote Post

KYA
Group Icon



post 28 Nov, 2008 - 06:22 PM
Post #38
bonnie, I'll look into seeing if that would be worth its own tutorial.
Go to the top of the page
+Quote Post

darkrut
*



post 1 Dec, 2008 - 01:42 AM
Post #39
i have a problem! if the condition is true at the first while it works...but at the second "while" it doesn't delete the node that the condition is true for!thank you for helping me
CODE
//....
struct node  
{  
   string kelima;  
   int compteur;
   node *link;  
};// .........
void delnode(int n)
            {      node*temp;
                   node*teo;
                
                  
                  
                         while(top->compteur<n)
                         {  
                                top=top->link;if(top==NULL)break;
                         }temp=top;
                        
                          while(temp!=NULL)
                          { if(temp->compteur!=n)
                                {
                                teo=NULL;
                                 teo=temp->link;
                                
                                 temp=teo;
                                }
                             
                                    
                            else temp=temp->link;
                        }        
                        
                              
                            
             }
Go to the top of the page
+Quote Post

violaris
Group Icon



post 1 Dec, 2008 - 03:04 AM
Post #40
This is so great, I have passed my Data Structures midterm by only following this tutorial and practicing with it!
Go to the top of the page
+Quote Post


3 Pages V < 1 2 3 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 11/21/09 03:09PM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month