Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ChangeStructVal
//gcc 7.4.0 //ChangeStructVal: Swapping two structures //this code is created by Rezaul Hoque on March 25,2022;contact: jewelmrh@yahoo.com,Dhaka, Bangladesh //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <stdio.h> #include <stdlib.h> #include <string.h> struct example { int a; char ch[30]; double d; }var1, var2; void swap(struct example*,struct example*); void input(); void display (); void swap(struct example* var1,struct example* var2){ struct example t; t=*var1; *var1=*var2; *var2=t; } void input(){ var1.a=10; strcpy(var1.ch,"hi"); var1.d=123; var2.a=20; strcpy(var2.ch,"hello"); var2.d=456; } void display (){ printf("var1:\n"); printf("a: %d\t",var1.a); printf("ch: %s\t",var1.ch); printf("d: %0.2f\n",var1.d); printf("var2: \n"); printf("a: %d\t",var2.a); printf("ch: %s\t",var2.ch); printf("d: %0.2f\t",var2.d); } int main(){ input(); printf ("Before swap:\n"); display(); swap(&var1,&var2); printf("After swap:\n"); display (); return 0; }
run
|
edit
|
history
|
help
0
Vereinfachung
Welcome1
MyWall1
SOLUCION USANDO UN CICLO Y PUNTERO
qsort
printing numbers without using loop
Sunday assignment late v3
PREGUNTA 2, GUÍA 4, MÓDULO 3
Spring 2017 Project 2 v.04
Assignment 5 part 2 v2