Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Pls help me with the solution of this program

sameer23chdsameer23chd Posts: 1Member
using System;
using System.IO;
public class InsertTabs
{
private const int tabSize =4;
private const string usageText ="Usage: INSERTTABS inputfile.txt ,outputfile.txt";
public static int Main(string[] args)
{
StreamWriter writer = null;

if(args.Length <2)
{
Console.WriteLine(usageText);
return 1;
}
try
{
writer =new StreamWriter(args [1]));
Console.SetOut(writer);
Console.SetIn(new StreamReader (args[0]));
}
catch(IOException e)
{
TextWriter errorWriter = Console.Error;
errorWriter.WriteLine(e.Message);
errorWriter.WriteLine(usageText);
return 1;
}
string line;
while (( line = Console.ReadLine()) !=null)
{
string newLine =line.Replace((" ").PadRight(tabSize, '), " ");
Console.WriteLine(newLine(newLine);
}
writer.Close();
StreamWriter standardOutput = new StreamWriter(Console.OpenstandardOutput());
standardOutput.AutoFlush =true;
Console.SetOut(standardOutput);
Console.WriteLine("INSERTTABS has completed the processing of {0} " ,args[0]);
return 0;
}
}

It has an error of newline in constant and i dont know how to remove that error.pls tell me its solution

Comments

  • xxbv70xxbv70 Posts: 1Member
    using System;
    using System.IO;
    public class InsertTabs
    {
    private const int tabSize = 4;
    private const string usageText = "Usage: INSERTTABS inputfile.txt ,outputfile.txt";
    public static int Main(string[] args)
    {
    StreamWriter writer = null;

    if (args.Length < 2)
    {
    Console.WriteLine(usageText);
    return 1;
    }
    try
    {
    writer = new StreamWriter(args[1]);
    Console.SetOut(writer);
    Console.SetIn(new StreamReader(args[0]));
    }
    catch (IOException e)
    {
    TextWriter errorWriter = Console.Error;
    errorWriter.WriteLine(e.Message);
    errorWriter.WriteLine(usageText);
    return 1;
    }
    string line;
    while ((line = Console.ReadLine()) != null)
    {
    string newLine = line.Replace((" ").PadRight(tabSize), "/t");
    Console.WriteLine(newLine);
    }
    writer.Close();
    StreamWriter standardOutput = new StreamWriter(Console.OpenStandardOutput());
    standardOutput.AutoFlush = true;
    Console.SetOut(standardOutput);
    Console.WriteLine("INSERTTABS has completed the processing of {0} ", args[0]);
    return 0;
    }
    }

    just check it, you define newline as a string value not a method.You cannot use a value as a method.

Sign In or Register to comment.