How can I search the data? I want to get the output like this. Anyone can explain to me? Thanks in advance.
==============================
Enter a data to search: 44
DATA FOUND!
==============================
To search in a linked list, you'll start at the first node and traverse the list, checking to see if the value you're looking for is in the data member of current node or if you've reached the end of the list without finding the value.
That code is searching all the elements of an array (assuming that the n in the for loop is the size of the array) for a value equal to what the user entered for target. If there is a match, an int variable found gets set to 1.
You already have code that traverses the linked list when you print all the values in the list. Instead of printing the values, now you want to check if the data in the node is equal to the value input. temp->data == target. A bool variable can be set to true if the value is found.
I don't know if the assignment requires this all be in the main function, but I'd usually break a program like this into separate functions.