c++ function to convert a linear list to circular list


 
Thread Tools Search this Thread
Top Forums Programming c++ function to convert a linear list to circular list
# 1  
Old 08-25-2010
Question c++ function to convert a linear list to circular list

hi all,

i need a c++ function which converts a linear list to circular.
presently i am working with two files. i.e., one linear list file. and one circular list file to do some operations. i thought it will be helpful if there is a function that converts a linear list to circular n undo the same whenever required.....
Please help me........
# 2  
Old 08-25-2010
Code:
typedef struct node {
   int list_data;
   struct node *next;
} NODE;

void Linear2Circular (NODE *list) {
   
   NODE *tmp = list;
   if(NULL != tmp) {
      /*
      ** The list has one or more nodes.
      */
      while (NULL != tmp->next)
         tmp = tmp->next;

      tmp->next = list;   //Converted into the circular formation.
   }
}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert list of numbers to text range

Hi, I'd like to take a list of numbers (with a prefix) and convert to a range, for example: cn001 cn004 cn016 cn017 cn018 cn019 cn020 cn021 cn031 cn032 cn038 cn042 cn043 cn044 cn045 (5 Replies)
Discussion started by: chrissycc
5 Replies

2. Shell Programming and Scripting

Convert a two-column list into a csv

Hi experts, I have a very large (1.5M lines), sorted but unstructured list that looks like this: process_nameA valueA process_nameA valueA ... process_nameB valueB process_nameB valueB ... process_nameN valueN I'd like to turn this into a csv. The values are all... (4 Replies)
Discussion started by: abercrom
4 Replies

3. UNIX for Dummies Questions & Answers

How convert space separated list to matched columns?

Hi I have been racking my (limited) brains to get this to work without success I have a file output which is a list of lists - ie a single column of data that is separated by space into sub lists below - I need to both split this so that each list is in a separate column (eg tab or semicolon... (8 Replies)
Discussion started by: Manchesterpaul
8 Replies

4. Shell Programming and Scripting

Convert a list of word/terms into their Regexp representation

Ok this might sound pretty weird but here is the request. Running on a linux system in bash or Perl (i really don't know perl but the end user has a few pearl script already) Start File looks something like this (4000 entries) TEST PLAN T//TF T-TF TEST (T) Hacker ... I am thinking about... (3 Replies)
Discussion started by: oly_r
3 Replies

5. Shell Programming and Scripting

Script to convert row to list

Hello, I have data which is basically a set of rows in which names having the same homophonic values are stored. I want to convert the data into lines such that the first word of the database is treated as the anchor and each subsequent word is appended to it with a column. An example... (5 Replies)
Discussion started by: gimley
5 Replies

6. Shell Programming and Scripting

convert list in a command

Hello, i would make a script that generate SWITCH commands to create zone in a SAN, i have this file: ## zone:z_CGBVMH1_FC0_to_EVA1_CTRL_A_1 p_CGBVMH1_FC0; p_EVA1_CTRL_A_1 ## zone:z_CGBVMH1_FC0_to_EVA1_CTRL_B_1 p_CGBVMH1_FC0; p_EVA1_CTRL_B_1 ## zone:z_CGBVMH1_FC2_to_EVA1_CTRL_A_1... (2 Replies)
Discussion started by: alen192
2 Replies

7. Programming

c++ code to check whether a list is circular or not

hi all, i need c++ code to check whether a list is circular or not... please help (8 Replies)
Discussion started by: vidyaj
8 Replies

8. Programming

Linear linked list node delete

Given an in-between(any node not at the start and end of the linked list) node within a singly linear linked list, how to delete that node, when head pointer of list is not given? (13 Replies)
Discussion started by: rupeshkp728
13 Replies

9. Shell Programming and Scripting

Convert perl qw list to text file list?

Does anyone have a good example? I am having trouble looping.. Thanks (1 Reply)
Discussion started by: mrlayance
1 Replies

10. Shell Programming and Scripting

Splitting a list @list by space delimiter so i can access it by using $list[0 ..1..2]

EDIT : This is for perl @data2 = grep(/$data/, @list_now); This gives me @data2 as Printing data2 11 testzone1 running /zones/testzone1 ***-*****-****-*****-***** native shared But I really cant access data2 by its individual elements. $data2 is the entire list, while $data,2,3...... (1 Reply)
Discussion started by: shriyer
1 Replies
Login or Register to Ask a Question