Swap different size string


 
Thread Tools Search this Thread
Top Forums Programming Swap different size string
# 1  
Old 06-29-2010
Swap different size string

how can I write a function to swap to different sized string?
# 2  
Old 06-29-2010
Code:
void swap2str(char *a, char *b)
{
     char *tmp=malloc(strlen(a)+strlen(b)+2);
     strcpy(tmp,a);
     strcpy(a,b);
     strcpy(b,tmp);
     free(tmp);
}

One way. This requires that the original strings are each declared as big enough to hold the other -
i.e.,
Code:
char a[32]={0x0};
char b[32]={0x0};
strcpy(a, "junk");
strcpy(b,"even more junk");
swap2str(a,b);

# 3  
Old 06-29-2010
thanks jim for the reply
the first method is more promising
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

/tmp size is less whereas size allocated to swap is more

Hi, the /tmp size is less whereas the size allocated to swap is quite big. how to increase the size of /tmp - #: swap -l swapfile dev swaplo blocks free /dev/md/dsk/d20 85,20 8 273096 273096 #: swap -s total: 46875128k bytes allocated + 2347188k reserved =... (2 Replies)
Discussion started by: psb74
2 Replies

2. HP-UX

Determing size of swap space

Hi Experts, Need your advise in determining the size of swap space in of the new HP-Ux server. Server is having 32G of physical memory. Ideally what amout of physical memory should be allocated as a swap space? Following document from HP suggests to have minimum swap space... (2 Replies)
Discussion started by: sai_2507
2 Replies

3. AIX

SWAP SIZE Recommended.

Dear All, During installation of SAP, it shows like below : Condition : Swap Size Result Code : Condition not met Severity : MEDIUM Message : For the selected services at least 74228 MB swap space are recommended. Current value: 65536 MB. (Updated 2005-06-24) I am working on AIX OS. ... (8 Replies)
Discussion started by: kak
8 Replies

4. Solaris

Help on Understanding Swap Size

Hi All, I want to know how to understand the actual swap size. My o/p shows as below root@ecovs1a # swap -s total: 4546056k bytes allocated + 358856k reserved = 4904912k used, 5046688k available root@ecovs1a # swap -l swapfile dev swaplo blocks free /dev/md/dsk/d31 ... (9 Replies)
Discussion started by: vivek.goel.piet
9 Replies

5. Solaris

Swap size increase

Dear All, How to increase the swap size when physicall memory reaches 60 %. OR it can be only done after the physicall memory is full. Rgds Rj (8 Replies)
Discussion started by: jegaraman
8 Replies

6. UNIX for Dummies Questions & Answers

swap memory and original size of HD

few questions a. where can I find the RAM of a server? im about to install redhat on a server (reformat). need to know because it will be my basis for swap size. i saw something line 3048MB detected upon boot. is this the memory? b. what is the command in lunux to check the original size of... (2 Replies)
Discussion started by: lhareigh890
2 Replies

7. UNIX for Dummies Questions & Answers

Size of swap partition during installation

Greetings. I've been into computers since the '80s, but this is my first attempt at Linux. I'm installing Debian Lenny on a PIII 733 with 10GB hard drive and 512MB Ram. I intend to use the machine primarily as a development server, with things like mySQL, Apache, php, etc. I don't really want... (22 Replies)
Discussion started by: fguy
22 Replies

8. Solaris

Weird swap size on Solaris 9

I have a machine: SunOS <server> 5.9 Generic_117171-15 sun4u sparc SUNW,Sun-Fire-480R It has these filesystems: Filesystem size used avail capacity Mounted on /dev/md/dsk/d0 19G 15G 3.9G 80% / /proc 0K 0K 0K 0% /proc... (6 Replies)
Discussion started by: son_t
6 Replies

9. HP-UX

Increasing swap size

We increased our server's RAM 8 -> 32 GB RAM. swap memory is currently 10 GB. With which command I can increase this memory? (1 Reply)
Discussion started by: akyuceisik
1 Replies

10. UNIX for Dummies Questions & Answers

Size of swap

Hy all, i've a little problem with the size of the swap. I've an old solaris machine, with 4Go, and swap is taking 500Mo for only 1% used at any time. So : how can i change this size without problems ????? (ok it may be a stupid question, but it's a real problem when you lose about 1 or 2... (3 Replies)
Discussion started by: Olivier
3 Replies
Login or Register to Ask a Question