Thread: Simple function that I tried to build.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Registered User Sargnagel's Avatar
    Join Date
    Aug 2002
    Posts
    166
    Damn, you were faster.
    Really not bad for a 5 h newbie!
    But anyway here is my interpretation of the substring() function of JAVA. It's very basic and not secure!

    Code:
    #include <stdio.h>
    
    int strll(char str[]);
    void sub(char string[], int min, int max);
    
    int main()
    {
    	char str[10];
    	int start, end;
    	printf("String: ");
    	gets(str);
    	printf("\nstart: ");
    	scanf("%d", &start);
    	printf("\nend: ");
    	scanf("%d", &end);
    	
    	sub(str,start-1,end-1);
    	
    	return 0;
    }
    
    void sub(char string[], int min, int max)
    {
    	int i;
    	
    	for(i = min; i <= max; i++)
    	{
    		printf("%c", string[i]);
    	}	
    }
    Last edited by Sargnagel; 10-23-2002 at 03:51 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  2. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM