Need Help with Code

Need Help with Code
0.0 0

#1

Hey guys, I need help with a coding assignment for a class. Its been almost 3 years since I’ve last touched a coding program, so I’m a little rusty, and would like some help getting started.

For my assignment, I have to write a program that reads in lines of input, redirects files, process those files, and then outputs the results on a Linux server.

Does anyone know how to do this? I’ve had some experience with C++ and Java, but I’ve never once touched Linux or know about Linux commands.


#2

This is a pretty vague request, what exactly do you meant “output the result”?
You want to save a file there, echo a command…

Also do you have permission to read-write on that server?

That said cat is a shell command to read a content of a file
so

cat /path/to/file

will display the content of the file on the screen.
You can also write the content of the file into a new file

cat /path/to/file > /temp/file.txt

You can then concatenate command as:

<file> | ssh user@Server "cat > output.txt"

more on cat

Good luck with your assignment :slight_smile:


#3

Thanks! Here’s a direct quote from the assignment on the request:

You are to write a program that reads in lines of input using scanf, and file redirection, process the data, and then output
the results using printf.

The data:

  1. Each line of the data file begins with an ‘e’, ‘c’, or ‘t’.
  2. Lines beginning with ‘e’ will have an integer employee ID and an employee name.
  3. Lines beginning with ‘c’ will have an integer customer ID, customer name, and a floating point account balance.
  4. Lines beginning with a ‘t’ will have a customer ID, employee ID, a ‘w’ or ‘d’ representing withdrawal or deposit,
    and a floating point transaction amount.
  5. Lines beginning with an ‘e’ and ‘c’ may be intermingled, but all ‘e’ and ‘c’ lines will come before lines beginning
    with ‘t’.
  6. There will be at most 50 employees and 50 customers, and an unknown number of transactions. Names will be at
    most 15 characters long.

I understand most of it, all that’s confusing to me is the file redirection using Linux servers. Everything else sort of makes sense, but if someone would like to give me an idea of how to get started, I’d appreciate it a lot.


#4

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at http://freecodecamp.com.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile: