C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-18-2009, 12:31 PM   #1
Registered User
 
Join Date: Oct 2009
Posts: 22
Question Printing a substring based on char start and stop number

Say I have a string (an array of characters) that is 1000 characters long. I want to print a substring made up of the characters 50 to 100. How do I do that?

-I have looked at the string library and don't recognize a solution.
-Should I create a new smaller array somehow --- perhaps a loop?

yep, I'm a newb.
Roger is offline   Reply With Quote
Old 10-18-2009, 12:45 PM   #2
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
You need to look at the string library again, with the caveat that the words they use may not exactly match the words you are using. For instance, there's strncpy.
tabstop is offline   Reply With Quote
Old 10-18-2009, 01:05 PM   #3
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 4,923
If you just want to print it, simply start at index 49 and print up to index 99. If you want to make a copy use a similar approach, but instead of printing, copy the data to a buffer somewhere (don't forget to null terminate the string, though).
Sebastiani is offline   Reply With Quote
Reply

Tags
string, strings

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unkown Hang Bladactania C Programming 31 04-22-2009 09:33 AM
C programing doubt sivasankari C Programming 2 04-29-2008 09:19 AM
why cant i start the process i stop using SIGCONT cruxxe C Programming 0 06-06-2002 09:06 AM
simulate Grep command in Unix using C laxmi C Programming 6 05-10-2002 04:10 PM


All times are GMT -6. The time now is 12:00 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22