copy string in c 2b 2b

Solutions on MaxInterview for copy string in c 2b 2b by the best coders in the world

showing results for - "copy string in c 2b 2b"
Roberto
13 Jan 2020
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#define sg struct gammal
5struct gammal {
6    char name[20];
7    int payment;
8    struct gammal *next;
9};
10void add (sg *g){
11    char name[20];
12    int payment;
13    printf("Enter Name: ");
14    scanf("%s",name);
15    printf("Enter Payment: ");
16    scanf("%d",&payment);
17    if(g->payment == -1){
18        strcpy(g->name,name);
19        g->payment = payment;
20        g->next = NULL;
21    }
22    else {
23        while(g->next != NULL)
24            g = g->next;
25        g->next = (sg*)malloc(sizeof(sg));
26        g = g->next;
27        strcpy( g->name,name);
28        g->payment = payment;
29        g->next = NULL;
30    }
31}
32void show (sg *g){
33    while ( g != NULL){
34        printf("---------");
35        printf("%s ",g->name);
36        printf("%d ",g->payment);
37        g = g->next;
38    }
39}
40int main()
41{
42    sg *g =(sg*)malloc(sizeof(sg));
43    g->payment = -1;
44    add(g);
45    add(g);
46    show(g);
47}
Niko
13 Jun 2016
1//use '=' to copy string
2string s1={"Hello"};
3string s2;
4s2=s1;	//now s2 will have a copu s1
queries leading to this page
copy 28 29 string c 2b 2bcreate string copy c 2b 2bcopying a string in cppcopy function in string c 2b 2bcopy in c 2b 2b 5ccopy string cppcopy method c 2b 2bcopy 28 29 in c 2b 2bstring copy in c 2b 2bstring copy c 2b 2bget copy function c string c 2b 2bcopy of string in c 2b 2bstring copy constructor c 2b 2bstr c 2b 2b copycopy function c 2b 2bcopy string reference c 2b 2bhow to copy string c 2b 2bmake copy of string in c 2b 2bstr copy c 2b 2bhow to make a copy of a string in c 2b 2bcopy in c 2b 2bc 2b 2b string copy 28 29copy string c 2b 2bstring copy in cppcopy string in cppcopy of string c 2b 2bc 2b 2b copy define in stringspecific string copy c 2b 2b how to copy a string c 2b 2bcopy a string in cppc 2b 2b string copycopy string at c 2b 2bc 2b 2b copy 27stringcopy string cppphow to copy a string in c 2b 2bclone string c 2b 2bcreate copy of string c 2b 2bhow to make copy of string in c 2b 2bc 2b 2b copyhow to copy string value to another string cpphow to copy strings in cppcopy c 2b 2bc 2b 2b string copycopy function string c 2b 2bc 2b 2b clone stringhow to use string copy in c 2b 2bstr copy 28 29 string c 2b 2bstring copy c 2b 2bstring copy cppc 2b 2b copy functioncopying in cppcpp copycopy a value in c 2b 2bc 2b 2b copy stringhow to make string copy in c 2b 2bcopy std string c 2b 2bcopy a string in c 2b 2b copy 28 29 string c 2b 2bstring copy function c 2b 2bhow to copy string cppcopy in cppcopy string value using 3d c 2b 2bcopy 28 29 in cppmake copy of string c 2b 2bcopy 28 29 method c 2b 2bcopy 28 29 in stlc 2b 2b copy define inside stringcopy a string c 2b 2bcopy 28 29 c 2b 2bstring copy function in c 2b 2bs copy in cppstring copy function in cppc 2b 2b copy 28 29 stl copy in c 2b 2bcopy function in c 2b 2b for stringcopy cp in c 2b 2bc 2b 2b copy all stringcopy function in c 2b 2bcpp string copycopy string in c 2b 2b c 2b 2b str copyc 2b 2b string copystring copy in c 2b 2bcpp copy 28 29make a copy of string in c 2b 2bc 2b 2b string copy substringc 2b 2b copy a stringcopy string in c 2b 2b