The Problem of Converting Input Data to C Array

Back to General discussions forum

AnilAtaman     2019-09-02 09:14:10

Hello, I am writing from Turkey. I discovered CodeAbbey a month ago. I really like it and I enjoy writing code on it. However, As you guess, the given input data does not fit any language array format I know :). It is really timeconsuming to convert it to workable format. So, I would like to ask the admins if there is any chance to do changes on it ? I have already written pyhton script for myself. It could be tough for beginners. Thank you :):)

AnilAtaman     2019-09-02 10:27:50

I think I do something wrong :)))

Wojciech Morawiec     2019-09-02 18:09:18

Hey Anil,

I think one important skill to learn early nowadays is how to Google for solutions for you problem and apply the results to your situation. I don't mean to say "just Google it", far from it - I actually think that describing the problem one has in those terms that are used by other people using the programming language is not only a good way of structuring you own thoughts about your code, but also a core skill when it comes to communicating about programming in general.

So when you look at your problem, you see that you have lines of data which you somehow want to have access to element by element in your code. A first step might then be to get the whole line, then to separate it by the single space. Alternatively, one could try to read in character by character until you hit a newline \n character. The possibilities are many, and I think that with C not being able to use Python's input().split() and having to come up something creative teaches you a lot more.

Don't despair - not knowing something and searching everywhere is half the fun ;P

AnilAtaman     2019-09-02 19:12:26

Hey Wojclech,

Thank you so much for your kind advices :))

The problem is I don't even know scanf or cin can get data automatically until today :)

I generally made an array to solve the problem because I had not realized cin or scanf can work for it. This is my mistake

Please login and solve 5 problems to be able to post at forum