Tfw can't solve the exercises at the end of Chapter 1 on my own

>tfw can't solve the exercises at the end of Chapter 1 on my own

should I just give up

Attached: 1.png (792x1023, 107K)

Other urls found in this thread:

en.wikipedia.org/wiki/Digraphs_and_trigraphs#C)
pastebin.com/h8aJkMq7
twitter.com/NSFWRedditGif

post it so I can know wether or not I should feel superior

Attached: 2018-07-29 13_56_20.png (676x397, 78K)

Honestly I'd say that's kinda difficult for a beginner.
>inb4 "I could have done it"

this one? shit that's not even regular grammar
I guess writing full context-free C grammar parser is too much to ask, so it might be checking of consistency of pair elements. Solution could be stack: push opening elements and when encountering closing element, check if its opposite is on top and pop it.
The problem is strings and escaping. (also the digraphs and trigraphs en.wikipedia.org/wiki/Digraphs_and_trigraphs#C) and /* */ need 1 lookahead. Not sure if macros definitions affect anything.

Attached: Screenshot_2018-07-29_21-55-00.png (511x77, 10K)

If you can’t understand C a career in computer science is looking very promising for you.

It's really not that easy for a beginner.

I've been programming professionally in C# and JS for 5 years and these exercises would give me a few minutes of tought to do it in C. C strings are hard.

>face a challenge
>give up
Millennials, everyone

You should read the intro of the book.
There is a line there saying it is not for teaching programing but for employed programmers that want a taste of what C can do.

natural selection at work i guess

Repetition was key for me in getting the basics down. If you do not understand it and can not come up with the answer, find it online and study it and then re-implement it on your own later in the week or move forward and revisit it in the future. Never give up op.

Attached: serveimage.jpg (480x360, 19K)

I don't quite understand your meaning. Do you mind to explain it further?

Attached: 2018-07-29 14_13_06.png (864x94, 23K)

He's saying that it's not meant as "babby's first programming book". It's meant for people who are already programmers and just haven't used C yet.

Just have a state variable inComment tell you to discard all opening and closing blocks excluding the */

>people keep falling for this bait

I've only ever used C++ and have no clue about the standard libraries but I'd try this.
>1-20 and 1-21
>read in char array
>search char array for number of '\t' / 4 consecutive blanks that need to be replaced
>create new array with correct size
>write old array into new one while replacing tabs/blanks
1-22 and 1-23 sound relatively easy. 1-24 sounds like a lot of work.
But yeah, those are not exercises for complete beginners.

I am a novice. I am familiar with all of these things, I'm not a professional but I'm not completely new

Attached: 2018-07-29 14_15_17.png (985x133, 31K)

This. This. This.
Repetition is key.

This is how I do it:
Read other's solutions. Like merge sort in C.
Try to implement it on your own, from the beginning to the end. Don't mind if you feel/know some part of it is wrong. When you are done, consult the source material again and fix your mistakes. Change context for a few minutes. Come back and try it from memory again. Repeat until you get it 100% right.

This is the Benjamin Franklin's method, I've heard.

Once you've commited it effectively to memory, you can hold all of the algorithm at once in your head and try to analyze it all in your minds picture.


Don't mind if you feel like it's copying and you wouldn't be able to do it on your own. That's not how knowledge works.

Stop posting snippets from the book i know exactly what it says and you should open your eyes smart ass.

this. the C programming language is for people with programming experience who want to learn C.

here is my detab

Attached: detab.png (438x289, 21K)

okay I opened my eyes, it says it's an intro to C for novice programmers familiar with the basics, not for "pros who want a taste"

These aren't super difficult. The first one basically requires you to have a secondary string for storing the resultant string. Given that's the case I'd have no problems, as a teacher, if you used a secondary string for all the exercises. Basically you'd do something like this

char s2[n*strlen(s1)] //assume worst case scenario that every character is a tab.

int i, j, k;

for(i = 0;i

>inb4 hurr durr missing semicolon

and in_string state to discard any character after '\'

>If you can’t understand C a career in computer science is looking very promising for you.
Lmao ok

Go back to HN, faggot

Attached: Screenshot_2018-07-29-16-27-49-904_com.android.chrome.png (1080x1920, 247K)

My favorite computer science language is html.

Feed that program a long string and that VLA is going to overflow the stack

pastebin.com/h8aJkMq7

Lmao you busted him alright.


anyways, OP, if you are a newbie (and no shame in that!) start with K. N. King book.

what color scheme is this?

stock one, who cares

No, the book is good for learning C if you already have experience in programming
"Automate the Boring Stuff with Python" is probably the best absolute beginner's guide to programming without using a meme language like Scratch

If I want a book to learn C as an absolute and total beginner with zero knowledge what do I get?

I was going to read the book in op but after reading this thread maybe I shouldn't.

its my eyes. i have trouble with the contrast on many schemes. my stock ubuntu 18 is ok but it doesn't look like that

debian, XFCE, nano

kek

This. C programming a modern approach is an amazing book, I learned so much from it.

k&r2 is still an ok book for beginners.
the examples discussed in this thread are from the end of the "introduction" chapter. it's meant for experienced programmers who want to get a glance at enough of the language to get up and running quickly.
so, if you're a python programmer for example and you've written large applications or somewhat complicated software you should be able to tackle the exercises at the end of the chapter. it might take you a while but you should manage.
if you're an absolute beginner you can still read chapter 1 but the real business for beginners begins in chapter 2. exercise 2-2 wants you to write a for loop, for example.