Question

C Programming: I have a text file which has this on it 1 2 3 4...

C Programming:

I have a text file which has this on it

1

2

3

4

5

6

I want my output to display 123456

How do I do this?

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char filename[15];
    printf("Enter the filename: ");
    scanf("%s", filename);
   FILE* file = fopen (filename, "r");
    int i = 0;

    fscanf (file, "%d", &i);    
    while (!feof (file))
    {  
        printf ("%d", i);
        fscanf (file, "%d", &i);      
    }
    fclose (file);   
   return 0;
}
Add a comment
Know the answer?
Add Answer to:
C Programming: I have a text file which has this on it 1 2 3 4...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I have a text file with some quotes and I want to use php or laravel...

    I have a text file with some quotes and I want to use php or laravel to pull one quote at a time and display it to my website upon every page refresh. How do I use PHP or Laravel to pull one quote at a time from the text file (saved in my project as quotes.txt) and display it on my webpage? I am also open to using ajax and/or javascript.

  • Hi, i am working with MATLAB. I have a text file from which I have to...

    Hi, i am working with MATLAB. I have a text file from which I have to read in my data. So far i have this in my code. fid = fopen('ecgnormaloff.txt', 'r'); data = textscan(fid,'%f') According to all the websites, this should be enough to read in my points, however, I get this as my output data = 1×1 cell array {0×1 double} >> And when I try to access my data, there is nothing. I do not want to...

  • I have a question regarding java programming. If I have this in a text file, "...

    I have a question regarding java programming. If I have this in a text file, " hey you <hello world> " How can I get it so that it only extracts the words in between the "< > " ? I am doing this with a stream and I know you can get it with the .map() function but I cannot figure out how to do it.

  • I have a text file and want to rank entities by occurrences and output to a text file in the foll...

    I have a text file and want to rank entities by occurrences and output to a text file in the following format: e.g. Bob TAB person TAB 120 Scotland TAB location TAB 105 George TAB person TAB 83 After this I want to rank the co-occurrence (in a sentence) of the top 10 entity pairs and write to a text file: Bob TAB George TAB 20 Scotland TAB Bob TAB 15 etc... How do I do this in python?

  • In java, how can I convert this text file format: n=6 m=7 1 2 5 4...

    In java, how can I convert this text file format: n=6 m=7 1 2 5 4 9 5 6 2 3 2 3 4 3 5 6 2 6 4 2 // end of file into this text file format: 1,2,5 1,4,9 1,5,3 2,3,2 3,4,3 5,6,2 6,4,2 This is how to read the first text file: The first line of each file below contains the number of vertices and the number of edges in the graph (in the format "n=XXXX...

  • C Programming Files.. A file has lines of text and on each there are 3 integers....

    C Programming Files.. A file has lines of text and on each there are 3 integers. How to extract each of them from all lines and store in a linked list?

  • I have a text file and want to rank entities by occurrences and output to a...

    I have a text file and want to rank entities by occurrences and output to a text file in the following format: e.g. Bob TAB person TAB 120 Scotland TAB location TAB 105 George TAB person TAB 83 After this I want to rank the co-occurrence (in a sentence) of the top 10 entity pairs and write to a text file: Bob TAB George TAB 20 Scotland TAB Bob TAB 15 etc... How do I do this in python?

  • In c++. I have 6 different text files that I want my program to read during...

    In c++. I have 6 different text files that I want my program to read during different runs. How would I make it so that i can read a select whichi file I want it to read during each run?

  • JAVA Write a program that 1. opens a text file 2. reads lines of text from...

    JAVA Write a program that 1. opens a text file 2. reads lines of text from the file 3. Converts each line to uppercase 4. saves them in an ArrayList 5. Writes the list of Strings to a new file named "CAPSTEXT.txt" Mainjavo ext.txt Instructions from your teacher 1 My mistress' eyes are nothing like the sun; 2 Coral is far more red than her lips' red; 3 If snow be white, why then her breasts are dun; 4 If...

  • I am writing a program in C++, which requires me to read an input text file...

    I am writing a program in C++, which requires me to read an input text file using command line argument. However, I am using xcode on my Macbook to write C++ program, and use terminal instead of command. How do you use int main(int argc, char** argv[]) to read an input file. My professor requires us not to hard code the text file name like .open("example.txt"); Thank you!

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT