top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to perform bitwise logical operations on strings in C?

+1 vote
46 views
How to perform bitwise logical operations on strings in C?
posted Jun 16, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
Not clear about question. Can you please elaborate your question ?

1 Answer

+1 vote
#include <stdio.h>

void xorStrings(char* left, char* right) {
    int index = 0;

    while (left[index] != 0 && right[index] != 0) {
        left[index] ^= right[index];  // change operation here
        index++;
    } 
}

int main() {
    char a[] = "hello, world!";
    char b[] = "    ,foobar";

    printf("Before:\n%s \n %s\n", a, b);
    xorStrings(a, b);
    printf("After:\n%s \n %s\n", a, b);

    return 0;
}
answer Jun 17, 2015 by Shivaranjini
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...