# Thread: Help with Simple Programming

1. ## Help with Simple Programming

Hello! I am very new to C programming like literally from the scratch. It's part of my new job and I'm learning. My superior gave me a problem and for the life of me, I don't know how to figure it out.

How do you put this in C language:
For example

Input D 0,3

where D serves as dump memory (I'm not sure)
while 3 is the number of arrays or data

then the ouput will come out as

buf(0) 00 01 02

another example

Input D 5,4

Output

buf(5) 06 07 08 09

I hope my question makes sense hahaha
It's hard to learn programming if my superior speaks in a foreign language (Japanese) that I'm still not that fluent with

Thank you very much!

2. I'm guessing that since this is a job rather than school, you already have a sufficiently strong foundational programming background to pass the interview for this internship/junior role, but the issue is that you're completely new to the C programming language?

The first thing I'd do is to clarify the requirements as to the content of the data items. For example, I see the two sample outputs: "buf(0) 00 01 02" and "buf(5) 06 07 08 09". Initially, I thought that maybe you're supposed to fill the data items starting from 0. Then I see that "06 07 08" and that makes no sense to me. Like, if it means that you start 1 greater than the address, we would expect the first output to be "buf(0) 01 02 03" instead. Then I'd ask what is the format of these numbers: are they in decimal, or perhaps hexadecimal?

As for solving this with a C program: basically, you're reading a line of input and parsing it. It might be simplest to just have a sufficiently large array of char and then call fgets to read the line of input. As for parsing, there are several possible approaches, e.g., you could check for the "Input D " prefix, then you know exactly where the address and number of data item components begin, so with a little pointer arithmetic you have a pointer to the start of the substring that you can parse with sscanf, strtok + strtol, etc.

3. 1) See if there are any local programming standards you have to follow. Indentation, style, portability, licensing, compiler options. Maybe there is a template you can use as the basis for your program.

2) Work out the rough structure of the program - what does it have to do, how does it stop. Write it down.

For example
Code:
```This program must:

Print a hello message
read a line of input from the user
while the line of input is not empty
respond to that line of input
read another line of input from the user
Print an exit message```
You should able to use a search engine and a bit of intuition to work out how to do nearly all of those steps in the C programming language, apart from maybe the "respond to that line of input". Maybe when starting out assume that the requirement is to just print "The user entered '.....'", so you can check that works.

You will then be at the point of inspecting the user's input and acting on it.

3) If you get here, now you will want to work out how to 'parse' the user input to see if it is valid command, then act on it. When you get that far, come back and ask for more direction.