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
  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
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
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: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:46 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration