Table of Contents
The problem of using the SWAP function as an actual parameter in the C language.
Why can’t the C language swap function be implemented
Home web3.0 Which exchanges (currency exchanges) are CSWAP coins listed on?

Which exchanges (currency exchanges) are CSWAP coins listed on?

Jul 30, 2024 am 06:55 AM

Which exchanges (currency exchanges) are CSWAP coins listed on?

The problem of using the SWAP function as an actual parameter in the C language.

The relationship between formal parameters and actual parameters in C language is: the formal parameter is a copy of the value of the actual parameter. Regardless of the type of the parameter, the formal parameters passed to the subfunction are only the values ​​of the actual parameters. Therefore, when changing the value of the formal parameter variable itself, it has nothing to do with the actual parameters. In other words, changes to the formal parameters will not affect the actual parameters.

However, if the parameter type is a pointer type, you can change the data in the actual parameter address by modifying the data in the address pointed to by the pointer variable.

Therefore, when using the SWAP function to exchange data, two points must be guaranteed:

The parameter must be a pointer type, pointing to the data to be exchanged

When exchanging, the data in the address must be exchanged, not the address itself.

Reference code:

//Wrong exchange code 1

voidswap1(inta,intb)//The parameter is not a pointer to the data to be exchanged

{

intt=a;

a=b;

b= t;

}

//Wrong exchange code 2

voidswap2(int*a,int*b)

{

int*t=a;//Exchange the formal parameter variable itself

a=b;

b=t;

}

//Correct exchange code

voidswap(int*a,int*b)

{

intt=*a;//Exchange the data in the formal parameter variable address, Pointer variables remain unchanged

*a=*b;

*b=t;

}

Why can’t the C language swap function be implemented

The poster needs to have a deeper understanding of the parameters and return values ​​of the function~

First of all The return value of a function must be only one variable. The return(a,b) in your swap function may not pass the compilation~

At the same time, the parameters of the function can be passed in three forms: address, value, and reference. In your case, it is recommended to use the pointer method to directly modify the values ​​​​of a and b in swap. The code is as follows:

void swap(int*a, int*b)

{

int t;

t=*a;

*a=*b;

*b= t;

}

The method called in main is swap(&a,&b);

The above is the detailed content of Which exchanges (currency exchanges) are CSWAP coins listed on?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1252
24
OM Mantra Cryptocurrency Crashes 90%, Team Allegedly Dumps 90% of Token Supply OM Mantra Cryptocurrency Crashes 90%, Team Allegedly Dumps 90% of Token Supply Apr 14, 2025 am 11:26 AM

In a devastating blow to investors, the OM Mantra cryptocurrency has collapsed by approximately 90% in the past 24 hours, with the price plummeting to $0.58.

The Crypto Market Has Witnessed a Rebound Following the Recent Sheer Downturn The Crypto Market Has Witnessed a Rebound Following the Recent Sheer Downturn Apr 13, 2025 am 11:40 AM

The crypto market has witnessed a rebound following the recent sheer downturn. As per the exclusive market data, the total crypto market capitalization has reached $2.71Ts

TrollerCat ($TCAT) Stands Out as a Dominant Force in the Meme Coin Market TrollerCat ($TCAT) Stands Out as a Dominant Force in the Meme Coin Market Apr 14, 2025 am 10:24 AM

Have you noticed the meteoric rise of meme coins in the cryptocurrency world? What started as an online joke has quickly evolved into a lucrative investment opportunity

As Fear Drives Selling, BlockDAG (BDAG) Stands Out from the Crowd As Fear Drives Selling, BlockDAG (BDAG) Stands Out from the Crowd Apr 13, 2025 am 11:48 AM

As fear drives selling in the crypto market, major coins like Cardano and Solana face tough times.

Nightfall: A Privacy-Enhancing Protocol for Ethereum Blockchains Nightfall: A Privacy-Enhancing Protocol for Ethereum Blockchains Apr 13, 2025 am 10:48 AM

In the rapidly evolving world of blockchain technology, EY's Nightfall protocol has emerged as a significant development.

Bitwise Announces the Listing of Four of Its Crypto ETPs on the London Stock Exchange (LSE) Bitwise Announces the Listing of Four of Its Crypto ETPs on the London Stock Exchange (LSE) Apr 18, 2025 am 11:24 AM

Bitwise, a leading digital asset manager, has announced the listing of four of its crypto Exchange-Traded Products (ETPs) on the London Stock Exchange (LSE).

US Senate Draft Legislation Threatens to Hit Data Centers Serving Blockchain Networks and Artificial Intelligence Models with Fees US Senate Draft Legislation Threatens to Hit Data Centers Serving Blockchain Networks and Artificial Intelligence Models with Fees Apr 12, 2025 am 09:54 AM

The draft bill purportedly aims to address environmental impacts from rising energy demand and protect households from higher energy bills

Metaplanet Expands Its Bitcoin Treasury Holdings by Another 319 BTC Metaplanet Expands Its Bitcoin Treasury Holdings by Another 319 BTC Apr 15, 2025 am 11:20 AM

In an announcement made earlier today, Japanese firm Metaplanet revealed it has acquired another 319 Bitcoin (BTC), pushing its total corporate holdings beyond 4,500 BTC.