Troubleshooting an xlC Compiler Error

In summary, the issue with the program not working on the xlC compiler is likely due to it not reading the entire file before attempting to write to it. To fix this, you can use a while-loop to read each line of the file until the end of the file is reached and use an if-statement to check and modify the specific line before writing it to the outfile.
  • #1
lordentropy
6
0
Here is the problem, I made up this program and compiled it with the Big CC compiler and it worked perfect, just the way I wanted it to work, however I have to switch compilers and get it to work on an xlC compiler which I am not familiar with, and of course the program compiles but does not work how it was suppose to work.

The part that is an error, is where I need to 'copy and paste' a infile. I need control of certain elements of the infile so i can do manipulation on them and run a model program, however I still need the rest of the infile for calculation purposes as well, so my thought was just create an outfile, store what I need control of and outfile it, and then outfile the rest of the infile. Then i can make changes to certain elements and sent it through a loop so I would have multiple runs with the data changing only slighly.

However, what happens now is that I gets through the first run fine, then it fails at the 2nd run b/c it did not copy the infile properly and i get this error

1525-001 The READ statement on the file ram.in cannot be completed because the end of the file was reached. The program will stop.

here is the piece of my code acting up
do{

inFile.open("ram1.in");
outFile.open("ram.in");
outFile <<fixed << showpoint << setprecision(1);

getline(inFile,line);
outFile<<line<<endl;
inFile>>junk >>zs >> zr;
outFile<<inFrequency<<" " << zs <<" " << zr;
while(getline(inFile,line))
{
outFile<<line<<'\n';
}
inFile.close();
outFile.close();


Please help!
 
Technology news on Phys.org
  • #2
Thanks in advance.The issue you are having is likely due to the fact that your program is not reading the entire file before attempting to write to it. The xlC compiler is more strict than the Big CC compiler, and it will not allow you to modify a file if it is not completely read first. To fix this, you will need to make sure that all of the data in the file is read before attempting to write to it. To do this, you can use a while-loop to read each line of the file until the end of the file is reached. Then, you can use an if-statement to check whether the current line being read is the one that needs to be modified, and then use an else-statement to write the other lines of the file as-is. Something like this:while(getline(inFile,line)) { // Check if current line needs to be modified if (line == "junk zs zr") { outFile << inFrequency << " " << zs << " " << zr; } else { outFile << line << '\n'; }}inFile.close();outFile.close();
 
  • #3


Based on the error message and the code provided, it seems like the issue may be with the way the infile is being copied and pasted. It is possible that the code is not properly reading and writing the data from the infile, leading to the error when trying to access it again in the second run.

One potential solution could be to use a different method of copying the infile, such as using the "copy" function or using a buffer to read and write the data. It may also be helpful to check the documentation or seek assistance from others familiar with the xlC compiler to ensure that the code is being compiled and executed correctly.

Additionally, it may be beneficial to break down the code and test each step individually to identify where the error is occurring. This can help pinpoint the issue and allow for a more targeted solution.

I would also recommend checking for any differences in syntax or functionality between the Big CC compiler and the xlC compiler, as this could also be a factor contributing to the error.

Overall, troubleshooting compiler errors can be a challenging process, but with careful analysis and testing, it is possible to identify and resolve the issue.
 

1. What is an xlC compiler error?

An xlC compiler error is an error that occurs during the compilation process of a program written in the IBM XL C/C++ compiler. It indicates that there is a problem with the code and the compiler is unable to generate an executable file.

2. How do I troubleshoot an xlC compiler error?

To troubleshoot an xlC compiler error, you can start by checking the error message and understanding what it means. Then, you can review the code and look for any syntax errors or other issues. You can also try compiling the code with different compiler options or using a debugger to identify the source of the error.

3. What are some common causes of xlC compiler errors?

Some common causes of xlC compiler errors include syntax errors, missing or incorrect library files, incompatible code, and incorrect compiler options. Memory issues and conflicts with other programs or tools can also cause compiler errors.

4. How can I avoid xlC compiler errors?

To avoid xlC compiler errors, it is important to write clean and error-free code. This includes using proper syntax, avoiding deprecated functions, and following coding standards. It is also helpful to regularly test and debug your code to catch any potential errors before compiling.

5. Can I get support for troubleshooting an xlC compiler error?

Yes, you can seek support from IBM or other online communities to troubleshoot an xlC compiler error. You can also refer to the IBM XL C/C++ documentation for guidance on common errors and troubleshooting steps. Additionally, there are various forums and resources available where experienced developers can offer assistance and advice.

Similar threads

Replies
52
Views
4K
  • Programming and Computer Science
Replies
29
Views
2K
Replies
6
Views
1K
  • Programming and Computer Science
2
Replies
65
Views
4K
  • Programming and Computer Science
Replies
9
Views
3K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
2
Views
276
  • Programming and Computer Science
Replies
2
Views
795
  • Programming and Computer Science
Replies
5
Views
960
  • Engineering and Comp Sci Homework Help
Replies
14
Views
2K
Back
Top