The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled C Code
Posted by: Jae | September 6, 2010 @ 6:50pm
C Code
[
Download
]
/*********************************************************************************/ /* Assignment 1: String Delete Then Add ******************************************/ /* Name: Jaemyeong Eo *****************************************************/ /*********************************************************************************/ /*********************************************************************************/ /* Usual suspects to include *****************************************************/ /*********************************************************************************/ #include<stdio.h> #include<stdlib.h> #include<string.h> #include<unistd.h> /*********************************************************************************/ /* Global string which to operate on *********************************************/ /*********************************************************************************/ char string[1024]; /*********************************************************************************/ /* delete_then_add function ******************************************************/ /*********************************************************************************/ void delete_then_add( char *string, int len ) { int i=0; int count_as=0; int count_bs=0; count_as = count_bs = i; // get rid of warning // YOUR WRITE THIS FUNCTION -- it's short on code, but a little tricky to get right // first phase - remove the B's but don't pass over newling "\n" // second phase - add the a's starting at the back and move to the front of the string } /*********************************************************************************/ /* main function *****************************************************************/ /*********************************************************************************/ int main( ) { printf("Please enter a string with a's and b's in it: \n"); if( NULL == fgets(string, 1024, stdin)) { printf("Error in reading string from stdin"); exit(-1); } delete_then_add( string, strlen(string) ); printf("The new string is: %s\n", string ); return(0); }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.66 / 8
50 Votes
http://codebin.yi.org/829
page generated in 0.00 seconds