LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Closed Thread
 
LinkBack Search this Thread
Old 06-04-2011, 08:27 AM   #1
mecrazyme1234
LQ Newbie
 
Registered: Jun 2011
Posts: 4

Rep: Reputation: Disabled
i tried using this code for deleting a user given character from a user given string


#include<stdio.h>

#include<string.h>

char* reverse (char*,char);


int main()

{

char *name;

char *ch=name;

char c;

printf("\nEnter the string to be reversed and the character to be deleted");

scanf("%s%c",name,&c);

char* ret=reverse(ch,c);

printf("\nthe modified string is %s",ret);

return(0);

}





char* reverse (char* p,char t)

{ int l,i;

l=strlen(p);

printf("\n%d",l);

for(i=0;i<l;i++)

{

if(*p=='t')

{
while(*p!='\0')


{ *p=*(++p);

p++;

}


}

p++;

}

printf("%s",p);

return(p);
}
******************************************************
but it showed segmentation error..please help
 
Old 06-04-2011, 08:43 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Barcelona, Spain
Distribution: LMDE Gnome with Awesome WM + Kernel 3.3.0-1 amd64
Posts: 6,529
Blog Entries: 1

Rep: Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219Reputation: 1219
Hello,

Please don't double/cross post your question in more than one forum. That will only confuse you and us on where the conversation is taking place. Stick to your thread in the Programming forum. Reported as duplicate of this one.

Kind regards,

Eric
 
Old 06-04-2011, 04:59 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,625
Blog Entries: 10

Rep: Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Closed the original in favour of the more sensibly formatted & placed dupe:

http://www.linuxquestions.org/questi...string-884501/
 
  


Closed Thread

Tags
printf


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to change String using sed with a string \/home\/user\/Desktop icecoolcorey Programming 10 06-12-2008 11:32 PM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
deleting a user joe k Linux - General 3 12-08-2004 06:31 AM
Deleting a user leecming Linux - Newbie 8 06-12-2004 02:17 PM
Deleting a user? WorldBuilder Linux - Software 1 03-28-2003 11:58 AM


All times are GMT -5. The time now is 10:42 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration