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 6815881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:51:35+00:00 2026-05-26T20:51:35+00:00

I currently have a program that basically reads html from a webpage. After sending

  • 0

I currently have a program that basically reads html from a webpage. After sending the web server an http request, I get back a response where I use fdopen to read the socket:

FILE *webpage = fdopen(socket, "r");

then I have a loop that uses fgets to get each line and then print them to a file:

while(!feof(webpage)){
    fgets(newline, 1000, webpage);
    fprintf ...
}

This part of the program works fine, and I end up getting some test file like:

HTTP/1.1 200 OK^M
Date: Fri, 18 Nov 2011 04:42:40 GMT^M
Server: Apache/2.2.14^M
Accept-Ranges: bytes^M
Cache-Control: max-age=0^M
Expires: Fri, 18 Nov 2011 04:42:40 GMT^M
Vary: Accept-Encoding^M
Content-Length: 345235^M
Connection: close^M
Content-Type: text/html^M
X-Pad: avoid browser bug^M
^M
<html lang="en">
<head>
...

I want to find this newline that is right under xpad, and insert something right when this newline is found (basically do something right after the headers are printed. However, I’m not sure how to find the line, or what the ^Ms are for.

Currently I’m trying things like

if(newline == "\r\n"){
   ... 
}

or just “\n”, and it doesn’t work. I think its got something to do with the ^M but I’m not sure.

Thanks!

  • 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-05-26T20:51:35+00:00Added an answer on May 26, 2026 at 8:51 pm

    ^M (Ctrl+M) is the ascii carrige return, I believe you can search for just \r and not \r\n

    I think ideally you want to do a regex check and check for a new line character at the beginning for the line ie ^\n alternativly you could just check the .length and see if it contains a new line if its 0. You just want to make sure you don’t catch any false positves.

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

Sidebar

Related Questions

We have an app that currently installs itself into 'program files\our app', and it
I have written a program that reads in a File object (really an XML
I have some code that does custom drawing. Basically it is form fill program
I am currently writing a non-web program using mostly python and have gotten to
I currently have a small Java program which I would like to run both
Say I have a command line C program which is currently executing, and I
I have a cd , dvd. book media program. Currently, i am trying to
I currently have an MS Access application that connects to a PostgreSQL database via
We currently have a company email server with Exchange, and a bulk email processing
I currently have a fairly robust server-side validation system in place, but I'm looking

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.