User:Megan Hoogenboom/assignment4: Difference between revisions
(Created page with "== Finding text and replacing == <source lang=C> #include "stdio.h" #include "string.h" #include "ctype.h" void main() { char a = 'a'; if (ispunct(a)) { printf("...") |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Finding text and replacing == | == Finding text and replacing in C== | ||
===Experiment 1:=== | |||
<source lang=C> | <source lang=C> | ||
Line 18: | Line 22: | ||
printf("\n"); | printf("\n"); | ||
} | } | ||
</source> | |||
Output: | |||
<source lang=bash> | |||
NOCHAR | |||
</source> | |||
===Experiment 2:=== | |||
<source lang=C> | |||
#include "stdio.h" | |||
#include "string.h" | |||
#define MAXLINE 1000 | |||
int main () { | |||
char line[MAXLINE]; | |||
int linelen; | |||
int i; | |||
char a = '1'; | |||
if (ispunct(a)) { | |||
printf("CHAR\n"); | |||
} | |||
printf("\n"); | |||
return 0; | |||
} | |||
</source> | |||
Output: | |||
<source lang=bash> | |||
</source> | </source> |
Latest revision as of 01:23, 9 November 2010
Finding text and replacing in C
Experiment 1:
#include "stdio.h"
#include "string.h"
#include "ctype.h"
void main() {
char a = 'a';
if (ispunct(a)) {
printf("CHAR\n");
}
else {
printf("NOCHAR\n");
}
printf("\n");
}
Output:
NOCHAR
Experiment 2:
#include "stdio.h"
#include "string.h"
#define MAXLINE 1000
int main () {
char line[MAXLINE];
int linelen;
int i;
char a = '1';
if (ispunct(a)) {
printf("CHAR\n");
}
printf("\n");
return 0;
}
Output: