473,624 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting substring on given position

151 New Member
I am trying to get the substring or line at a given position.

#include <stdio.h>

int main ()
{
FILE * pFile;
pFile = fopen ( "example.tx t" , "w" );
fputs ( "This is an apple.\nWhat can be done on the apple\n" , pFile );
fseek ( pFile , 11, SEEK_SET);
fclose ( pFile );
return 0;
}

using seekg we can point to a particular position but i need substring which ends with newline after the position.
In the above case
I need output should be
apple.\n

How this can be implemented.Tha nks in advance.

Manish
Apr 1 '09 #1
2 1605
gpraghuram
1,275 Recognized Expert Top Contributor
After reading the line use strstr to find the position and then use strncpy to copy the string from a required position to end of the line.

Raghu
Apr 1 '09 #2
Man4ish
151 New Member
@gpraghuram
Thank you very much i was looking for getting line which can be done by using getline function. After that i will the method suggested by you.

Manish
Apr 1 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1357
by: Wim Roffal | last post by:
I have a table with a collection of links. For simple duplicates I can check with an index. But I want also check for more than one link from the same domain. So I tried the following: SELECT name,count(*) AS dcount, SUBSTRING(url,0,(LOCATE('/', url,9))) AS urlroot FROM complink GROUP BY urlroot The problem I have is that "SUBSTRING(url,0,(LOCATE('/', url,9)))" does not
62
31879
by: Jupiter | last post by:
Hey, I would like to know 2 things. 1)Is there any function (in C standard library) that extracts a substring from a string? 2)Is there any function (in C standard library) that returns the position of a substring in a string? Thx a lot...
17
14335
by: Olivier Bellemare | last post by:
I've tried to make a function that returns the middle of a string. For example: strmid("this is a text",6,4); would return "is a". Here is my code: char *strmid(char *texte, int depart, int longueur) { char *resultat = " "; char *temporaire = " "; int nbr;
3
10304
by: Tim Soliday | last post by:
I have been looking at regular expressions lately, and I'm hoping that maybe someone could help me? I am trying to find the position of a substring, and then returning the substring including any information that I might want whether it is to the left or right of that substring. For example: //Position of substring has already been determined
2
2021
by: David Filion | last post by:
Hi, I have a question about substring(), when I run the following query: prepaid=# select substring('15148300', 0, 5); substring ----------- 1514 (1 row)
2
6409
by: mallard134 | last post by:
Could someone please help a newbee vb programmer with a question that is driving me crazy. I am trying to understand a line of code that is supposed to return the domain portion of a valid email address. The following code works! ****************************************************************** strEmail = "j...@mydomain.com" String2 = strEmail.Substring(strEmail.IndexOf("@") + 1, _
1
9477
by: kamleshsharmadts | last post by:
I am using Ajax with struts in web application. from jsp i am calling a function of ajax.js onclick of a button. code of that call function which calling from jsp given as below:- onclick="retrieveURL('/application/home_page.do?processAction=ItinerarySearch','AfoHomeForm')" after clicking on button i am getting following error:- object does not support this property or method at statement (Which i have made it bold in js file)
3
2928
by: balakrishnan.dinesh | last post by:
Hi frnds, Im having a problem in searching out a particular substring in a string. Here the code: --------------------- <html> <script> var tmpString=" ";
4
2372
by: N00b13 | last post by:
I have a great JS menu but I have to update every page each time I want to change a link. Is there a way to store my links in a file and call it so i only change that file? (what I have tried so far has not worked, but then again my JS really never works :) ) my .js: if (typeof Scl == "undefined") { var Scl = {}; } (function()
0
8231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8614
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7153
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6107
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2603
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.