Hi...
I've been trying to make a program where the input is txt file, and the output will be saved in txt file. But, I keep getting error Message.
My code looks like this: -
#include <stdlib.h>
-
#include <stdio.h>
-
-
int main (){
-
int i,j;
-
float H [100][100];
-
-
FILE*in;
-
in=fopen("0.txt","rt");
-
FILE*out;
-
out=fopen("rotation0.txt","w");
-
if(in){
-
for(i=0;i<100;i++)
-
for(j=0;j<100;j++)
-
fscanf(in, "%f", &H[i][j]);
-
for(i=0;i<100;i++){
-
for(j=0;j<100;j++)
-
//printf("%d "H[i][j]);
-
printf("");;
-
}
-
}
-
else {
-
fprintf(stderr,"Cannot open file\n");
-
return 1;
-
}
-
for(i=0;i<100;i++){
-
for(j=0;j<100;j++){
-
printf("[%d][%d]=%f\n ",i,j,H[i][j]);
-
fprintf(out,"[%d][%d]=%f\n ",i,j,H[i][j]);
-
}
-
}
-
-
return 0;
-
fclose(in);
-
fclose (out);
-
}
-
The error message says:
"parse error before *"
" "out" undeclared"
I found a couple strange things; if I move FILE*in (line 8&9) below FILE*out (line 10&11), the error became:" "in" undeclared".
And if I use different compiler (I'm using cygwin currently), it works. unfortunately, I can't use the other compiler because it doesn't work if I increase the size of array.
Could you help me, please?
Thank you
1 2531 JosAH 11,448
Recognized Expert MVP
Swap lines #9 and #10; in C first define your variables, then use them in statements etc.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: slickn_sly |
last post by:
For some reason, I'm getting an error. It doesn't seem to be reading
my "input.txt" file. I'm trying to read the "input.txt" file which
consits of random integers and use insertion sort to sort them in
order. Then, i want to have the sorted integers go the file
"output.txt"
static final int MAX_NUM = 100;
public static void main( String args ) throws java.io.IOException
{
|
by: Eric Lavigne |
last post by:
Here is a shell command (MS-DOS):
debug\curve-fit <input.txt >output.txt
And here is a Python script that *should* do the same thing (and almost
does):
import os
inputfilename = 'input.txt'
outputfilename = 'output.txt'
|
by: Kostadis.Spirou |
last post by:
this is a programm that opens config.txt and reads the 2 lines that are
inside it,after that it copies them and i want to put them as
parametres at
ifstream examplefile (file1.data());
ofstream fout (file2.data());
but when i try to run it it doesn't work at all.
any suggestions what to change in my code?
#include <iostream>
|
by: MM |
last post by:
Hi there,
How can I change my code (below) so that I use an "input argument" to
specify the file name of the input file? For example, if I compile the code
and that the application then gets the name "splitdata", then I want to be
able to call my application with something like this (datafile.txt will then
be the name of the input file):
splitdata datafile.txt
|
by: Aalok |
last post by:
This is what i want to do.
Read a text file as an input and based on that file, Create an outpu
text file which saves the contents of the input file in a specifi
format in the output file.
I know how to read a text file and i can even display the contents o
the input file on the prompt. However i am trying to figure out how t
save the contents of the input file in a specific manner.
| |
by: Carlo Marchesoni |
last post by:
I really don't achieve to read a simple 'input.txt' with the following content:
Jürg (Hex: 4a fc 72 67)
to an identical 'output.txt'
I do the following (and tried with tons of different encodings):
private static void WriteFile() {
StreamWriter sr = File.CreateText("Output.txt");
try
{
using (TextReader tr = new StreamReader(new
|
by: jwright |
last post by:
I have decided to use a struct to collect my data. The input file is
comma dilineated between almost all of the fields. Here is the code I
have so far and a sample input and output file.
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
struct pyrll
|
by: Dic4000 |
last post by:
ÏÂÃæ³ÌÐò½¨Á¢²»ÁËÎļþ,²»ÖªµÀÄÄÀï³ö´íÁË?
Ö»Ï붨ÒåÒ»¸öfstreamÀàÐÍÀ´Íê³ÉÊäÈëÊä³öµÄ¹¤×÷.
#include<iostream>
#include<conio.h>
#include<fstream>
using namespace std;
|
by: dmoran21 |
last post by:
Hi All, I am working on a program to take input from a txt file, do
some calculations, and then output the results to another txt file.
The program that I've written compiles fine for me, however, when I
run it, it stalls and does nothing. I'm wondering if there's something
obvious that I'm missing. My code is below and any help would be
appreciated.
Thanks,
Dave
|
by: dwaterpolo |
last post by:
Hi Everyone,
I am trying to read two text files swY40p10t3ctw45.col.txt and solution.txt
and compare them, the first text file has a bunch of values listed like:
y
y
y
y
y
y
y
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |