Skip to content

Instantly share code, notes, and snippets.

@alexanderfalgui
Last active August 29, 2015 14:01
Show Gist options
  • Save alexanderfalgui/3d74a5cf778a79c74ec4 to your computer and use it in GitHub Desktop.
Save alexanderfalgui/3d74a5cf778a79c74ec4 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#define LIMIT 1024
void squeeze(char s1[], char s2[]);
/* TO StackOverflow USERS: THIS VERSION IS WHEN THE ERROR IS FIXED. */
/* Exercise 2-4. Write an alternative version of squeeze(s1,s2) that deletes each character in
s1 that matches any character in the string s2. */
main()
{
char str1[LIMIT], str2[LIMIT];
int c, d, i, j, lim;
i = j = 0;
/* concatenate each character in c to str1 */
lim = LIMIT;
while (lim > 0) {
c = getchar();
if (c == EOF || c == '\n') {
lim = 0;
}
else {
str1[i] = c;
++i;
}
}
str1[i] = '\0';
/* concatenate each character in c to str2 */
lim = LIMIT;
while (lim > 0) {
d = getchar();
if (d == EOF || d == '\n') {
lim = 0;
}
else {
str2[j] = d;
++j;
}
}
str2[j] = '\0';
}
/* Deletes each character in s1 that matches any character in the string s2. */
void squeeze(char s1[], char s2[])
{
/* Nothing here yet. */
}
#include <stdio.h>
#include <string.h>
#define LIMIT 1024
void squeeze(char s1[], char s2[]);
/* TO StackOverflow USERS: THIS VERSION IS WHEN THE ERROR OCCURED. */
/* Exercise 2-4. Write an alternative version of squeeze(s1,s2) that deletes each character in
s1 that matches any character in the string s2. */
main()
{
char str1[LIMIT], str2[LIMIT];
int c, i, j, lim;
i = j = 0;
/* concatenate each character in c to str1 */
lim = LIMIT;
while (lim > 0) {
c = getchar();
if (c == EOF || c == '\n') {
lim = 0;
}
else {
str1[i] = c;
++i;
}
}
str1[i] = '\0';
/* concatenate each character in c to str2 */
lim = LIMIT;
while (lim > 0) {
c = getchar();
if (c == EOF || c == '\n') {
lim = 0;
}
else {
str2[j] = c;
++j;
}
}
str2[j] = '\0';
}
/* Deletes each character in s1 that matches any character in the string s2. */
void squeeze(char s1[], char s2[])
{
/* Nothing here yet. */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment