Great! Thank you very much. Got it.
Type: Posts; User: alter.ego
Great! Thank you very much. Got it.
I agree I messed up with the braces and the title. This was under captioned chapter hence I posted it that way. Sorry.
void squeeze(char s[], char c)
{
int i, j;
for (i = j = 0; s[i] != '\0';...
K&R trying to explain increment & decrement operator through this illustration:
/* squeeze: delete all c from s */
void squeeze(char s[], int c)
{
int i, j;
for (i = j = 0; s[i] != '\0';...
@std10093 @Barney Now it does look quite obvious. Thanks for your help.
Thanks! So you saying (in other words) while that concatenation is happening it's not getting printed because of '\0'?
I am trying to understand postfix & prefix increment and decrement operators from K&R book. They have given a string concatenation example:
/* strcat: concatenate t to end of s; s must be big...
Excercise:
My solution has not taken the final shape. Right now I am stuck in the last else-if. Program is working fine if l < 4 but not when l>4. I've been trying to debug for a while before...
^^ Thanks! Haven't yet reached the chapter on Pointers & will definitely refer it once I am there.
Great! Much clearer now. Thanks!
Thanks guys, much appreciated. But what about, say there was another function say CountWord(...,...), taking input as another character array, how would have copy() responded then?
This code is a direct paste from K&R:
#include <stdio.h>
#define MAXLINE 1000 /* maximum input line length */
int getline(char line[], int maxline);
void copy(char to[], char from[]); /*...
Whoops! HOW DID I MISS IT!!!?
Also I did an elementary mistake of keeping ++i outside the loop & it kept getting reseted to 0. Code works now!
Thanks hk_mp5kpdw, itsme86 & AndiPersti for all...
How do I use macro in the function, I may get an 'undefined variable error' (apologies if I am missing on something)?
Thanks for pointing it out. My minor tweaked code is as under, pasting it...
I am trying to solve this problem from K&R book.
My solution
#include <stdio.h>
#include <stdlib.h>
#define MAXLINE 10
Thanks! That helped & thanks for giving reasons behind it too.
Hi,
I am trying to work on a "simple" problem from K&R book. The excercise is as under:
My attempt:
#include <stdio.h>
#include <stdlib.h>
@laserlight @Tibo-88: Thanks for quick revert. It was not typo; I was flummoxed seeing expression "x<=y" in ternary operation. But thanks for clarifying.
#include <stdio.h>
#include <stdlib.h>
inline int min(int x, int y) { return x = y ? x : y; }
int main(int argc, char** argv) {
int x = 1;
Thanks for the help everyone. I have managed to get some output from the program. It helped me clear some concepts.
#include <stdio.h>
#include <stdlib.h>
int main(void) {
const char...
Thanks for the heads up. Basis your input I've tweaked the code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
const char msg[15] = "blueberry";
int c;
int s[15];
I am trying to work on a problem mentioned in K&R book (Excercise 2-4).
I am not writing a separate function, I am trying to achieve squeeze(s1,s2) by writing the code in the main program...
I am learning C with a generous help from K&R book (and internet of course). I need some assistance in understanding as to how to use following function in my main program.
void strcat(char s[],...
Thanks :)!
Thanks for that detailed explanation on Function. I didn't say multiple values will be returned. Ok...at the risk of sounding absolute pinhead, here's what I understood:
Main program calls...
Thanks for taking out time for the explanation.
At this moment I don't want to return multiple value. I am just intrigued why multiple value isn't getting returned. As per my understanding since...