M
Matt
Ok, sorry for posting so much, but I just have alot of questions. Ok,
so It says to make a program to count blanks, tabs, and newlines.
So I made one:
#include <stdio.h>
/* Count tabs, newlines and blanks; version 1 */
int main(void)
{
int c, nl, tb, cb;
nl = 0;
tb = 0;
cb = 0;
while ((c = getchar()) != EOF)
if (c == '\n')
++nl;
if (c == '\t')
++tb;
if (c == '_')
++cb;
printf("%d\n%d\n%d\n", nl, tb, cb);
return 0;
}
Now here's what I don't understand:
if (c == '\t')
++tb;
That(\t) be a tab so when I put a tab in it should make the count 1,
but it doesn't.
And:
if (c == '_')
++cb;
Should add a number to the blank count when you make a space, but it
doesn't. Also I wasn't sure about what the '?' was for a blank
space(eh, what a noob your thinking). Yes, I know: I'm a noob.
Ok well, could someone help me? Again: sorry for posting and asking so
much.
so It says to make a program to count blanks, tabs, and newlines.
So I made one:
#include <stdio.h>
/* Count tabs, newlines and blanks; version 1 */
int main(void)
{
int c, nl, tb, cb;
nl = 0;
tb = 0;
cb = 0;
while ((c = getchar()) != EOF)
if (c == '\n')
++nl;
if (c == '\t')
++tb;
if (c == '_')
++cb;
printf("%d\n%d\n%d\n", nl, tb, cb);
return 0;
}
Now here's what I don't understand:
if (c == '\t')
++tb;
That(\t) be a tab so when I put a tab in it should make the count 1,
but it doesn't.
And:
if (c == '_')
++cb;
Should add a number to the blank count when you make a space, but it
doesn't. Also I wasn't sure about what the '?' was for a blank
space(eh, what a noob your thinking). Yes, I know: I'm a noob.
Ok well, could someone help me? Again: sorry for posting and asking so
much.