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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:32:26+00:00 2026-05-16T17:32:26+00:00

i have written a C programme which prints itself n times, but i can’t

  • 0

i have written a C programme which prints itself n times, but i can’t get how to reverse print the same n times.E.g, if the sample programme is :

hello

then the required output should be "olleh" for n=1.
Here’s my quine programme,

#include <stdio.h>
int main()
{
  int n;
  char c;
  FILE *f;
  f=fopen(__FILE__,"r");
  scanf("%d",&n);
 while(n--)
 {
 while((c=getc(f))!=EOF)
 putchar(c);
 fseek(f,0,0);
 }
  return 0;
} 
  • 1 1 Answer
  • 1 View
  • 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-16T17:32:27+00:00Added an answer on May 16, 2026 at 5:32 pm

    The easiest way would be to read the file into an array (like this answer), and then just reverse the array:

    void swap(char* a, char* b) {
      char tmp = *b;
      *b = *a;
      *a = tmp;
    }
    
    void reverse(char* arr, int size) {
      for (int i = 0; i < size/2; ++i) {
        swap(arr+i, arr + (size - (i + 1)));
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which i have myself written in java, but I want
I have written a multithreaded program which does some thinking and prints out some
I have written this program, which sorts some ints using a functor: #include<iostream> #include<list>
I have a debugging program which I've written to attach to a process and
Hi I have a program written in C++ in which one or two functions
I am beginning to port a program which is written in C and have
I have a simple program (written in Java) which uses the google protocol buffer
i have written a c program to which i pass in a script like
I have written a program which takes a file as input and whenever it
I have written an Objective-C framework which builds some HTML code with NSMutableString which

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.