473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to create a .txt file comparing the two rows from a file ?

I have a .txt file which contains 121 COLUMNS and 2 ROWS,now I want to create one new file new.txt which will contain only the class no(A,B,C) which is larger than the value 6 in ROW 2.How to create it?I have tried the following code.

my c.txt file look like following :

A B C D E ..... AAA
12 20 4 7 5 ..... 11

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include "conio.h"
  3. #include "stdlib.h"
  4. #include "string.h"
  5.  
  6.  
  7. int main()
  8. {
  9.     FILE *fp,*fq,*dd;
  10.  
  11.     char Garbage[500];
  12.     int a1[500];
  13.     int i=0;
  14.  
  15.     fp=fopen("c.txt","r");
  16.     fq=fopen("c.xt","r");
  17.     dd=fopen("out.txt","w+");
  18.  
  19.     if(fp==NULL)
  20.     {
  21.     printf("\nNot Exists\n");
  22.     exit(1);
  23.     }
  24.  
  25.  
  26.     for(i=0;i<=121;i++)
  27.     {
  28.     fscanf(fp,"%c",Garbage[i]);
  29.     }
  30.  
  31.     for(i=0;i<=121;i++)
  32.     {
  33.     fscanf(fq,"%d",a1[i]);
  34.     }
  35.  
  36.     if(a1>20)
  37.  
  38.     {
  39.         fprintf(dd,"%c\n",Garbage);
  40.  
  41.     }
  42.  
  43.  
  44.     fclose(fp);
  45.     fclose(fq);
  46.     fclose(dd);
  47.     return 0;
  48. }
  49.  
  50.  
  51.  
  52.  
  53.  
Nov 21 '13 #1
0 955

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

Similar topics

0
by: aure_bobo | last post by:
Hi all, I'm currently developing an ASP.NET 1.1 C# Webapp. I have some objects which contains the differents parameters of my web app. These objects are instanciated in my code, in a static...
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
1
by: Guoqi Zheng | last post by:
Dear sir, Dataset offer and nice method to write an xml file. However, I do not know how can I add extra attribute to this xml file. The following is my script to creat a XML file, I want to add...
7
by: Daniel Walzenbach | last post by:
Hello, I want to create a Word XML file based on the input users make in a VB.NET application. I imagine creating a template in Word and saving it as a XML file. I then want to fill the...
10
by: Minh | last post by:
I search in all the Disscussion but can not found. How can I create a MS Access Database file using C# code with a given Table Structure ? For example, I want to create a Access Database File...
0
ADezii
by: ADezii | last post by:
Rather than using CurrentProject.Connection or entering your own Connection information, ADO supports storing Connection information in an external file called a Data Link File (which normally has a...
1
by: ATSPSoft | last post by:
Hi, I'm newest in c#.. i need to create an Access MDB file... Supose that my MDB file is "mymdb" and my table is "mytableA" with 2 fields like "field1" as integer and "field2" as string How...
6
by: mohamed azaz | last post by:
hi I want to know how can I create a simple doc file to drive D in Harddisk by using c++ code please answer me Quickly bye bye
7
by: mingke | last post by:
I have some images 100x100 pixels and save the value of pixels in *.txt file. I have to use this txt files as input for iteration. But I don't know how to make the code to recognize the...
1
by: saikat bose | last post by:
We create our c# dll file using the visual studio 2010. So first from file menu select the project option, then select the class library,named it as you wish after cliking ok by default a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.