Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9140845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:34:10+00:00 2026-06-17T09:34:10+00:00

Possible Duplicate: memcpy and malloc to print out a string I need to find

  • 0

Possible Duplicate:
memcpy and malloc to print out a string

I need to find the number of characters in a line of a text file after a ‘=’ sign until the end of the line or the ‘#’ symbol. I then need to work backwards till I reach the first non blankspace and use memcpy to print out the string.

Example: if the line said: myprop=this is a sentence #value, I need it to print out :”this is a sentence”. here is the code after I open the file and malloc it.

while(fgets(buffer, 1024, fp) != NULL)
{
 if((strstr(buffer, propkey)) != NULL)
 {
  for (

   //need help here


  memcpy(value, buffer + 7, 7);  //the 7 represents the # of characters till the equal sign
  printf("\nvalue is '%s'\n", value);
  }
 } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:34:11+00:00Added an answer on June 17, 2026 at 9:34 am

    You find the '=' via strchr().

    Loop from there until you hit either '\0' or '#'. Count the loops. Inside the loop, check for first non-blankspace (isspace()), and keep in mind (i.e., a variable) where you found it.

    After the loop, you have all the information you need: Copy (starting from remembered position of first non-blank) a number of bytes equal ( number of loops – position of first non-blank ).

    That being said, once you’re out of tutorial / C in 21 days country, you should really use ready-made libraries for stuff like this..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Getting segmentation fault SIGSEGV in memcpy after mmap I'm using mmap() in
Possible Duplicate: MD5 algorithm in Objective C I need to hash a string using
Possible Duplicate: Parsing XML String in C# How to process the below XML file
Possible Duplicate: Find the “#” character in a string with Javascript How do I
Possible Duplicate: Find out the instance id from within an ec2 machine I am
Possible Duplicate: C# memcpy equivalent What is the equivalent of the memcpy function in
Possible Duplicate: Model.find(1) gives ActiveRecord error when id 1 does not exist If there
Possible Duplicate: Generic methods and multiple constraints I need a generic function that has
Possible Duplicate: Use grep to report back only line numbers I only want to
Possible Duplicate: What's the @ in front of a string in C#? This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.