Total members 11889 |It is currently Fri Mar 29, 2024 3:00 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Swapping the variables contents using pointers.
cpp code
#include <stdio.h>

void swap(int *a, int *b)
{
int t = *a;
*a = *b;
*b = t;
}

main()
{
int x = 15, y = 74;
printf("%d %d\n", x, y);
swap(&x, &y);
printf("%d %d\n", x, y);
}




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Swap Using Pointers
 list swap in C++     -  
 swap two numbers c++ program     -  
 SWAP images using JQuery just by using the src attribute img     -  
 Arrays using Pointers     -  
 Types of Pointers in C++     -  
 How to use pointers and what it means     -  
 Basic Pointers     -  
 pointers to derived types     -  
 The using of pointers between two variables (Swaping)     -  
 Passing Pointers to function example     -  



Topic Tags

C++ Variables
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com