Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,037 questions

40,879 answers

573 users

How to return pointer to a string from a function in C

1 Answer

0 votes
#include <stdio.h>
   
char *rp(char *str);   
   
int main(int argc, char **argv) 
{ 
    char s[16] = "abc";
   
    puts(rp(s));
    
    return 0;
}

char *rp(char *str)
{
    char *p, *tmp;
    
    p = tmp = str;
    while(*p)
    {
         *p = *p + 1;
         p++;
    }

    return(tmp);
}
   
/*
  
run:
   
bcd

*/

 





answered Sep 28, 2015 by avibootz
...