Is there a function in c that will return the index of a char in a char array?
For example something like:
char values[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char find = 'E';
int index = findInedexOf( values, find );
...
I know some higher level languages, all web based (PHP, javascript, some python). I've finally decided to learn a lower level language, and I've decided to go with C. The problem is that all the languages I use are based heavily on OOP. Seeing as (based on the research I did) C doesn't have classes or inheritance. As a result, I ask y...
I am writing a script where I need to make sure they only put in certain characters. These include "x", "/", "+", "-", "%" (basic math operators), every letter from a -z and every number. I have the following below that only checks for alpha and number. How can I check that only certain one are used, and everything else, such as "&" or "...
I need to call a C++ member function from a C program.
I created .cpp/.h wrapper files in the C code, wrapping the C++ member functions.
i.e.- wrapper.cpp
#include "wrapper.h"
extern "C" {
void wrap_member1()
{
Class::member1();
}
void wrap_member2()
{
Class::member2();
}
}
and wrapper.h:
#include <windows.h>...
I'm writing a Valgrind tool and in the instrumented code I need to pass the guest's stack pointer to a dirty function. What I'm currently doing to get the stack pointer is this:
IRTemp temp = newIRTemp (sbOut->tyenv, gWordTy);
addStmtToIRSB (sbOut,
IRStmt_WrTmp (temp,
IRExpr_Get (offsetof (Ve...
I've got a TCP server and client written in C that opens up a connection that should be open forever. On the first send, errno returns 0 which is fine. On subsequent sends it gives me an errno 60 which is that the operation timed out. The packet is still recieved by the server though and nothing seems to be wrong. What could cause the th...
There are a few available and i want to support many platforms so i guess V8 isn't that good unless someone has written an interpreter patch for it.
...
int main(void) {
char x;
int y=1280;
x=y;
printf("%d", x);
}
OUTPUT: 0
I remember that int = 4 byte and char is merely 1 byte. So we're trying to squeeze a 4 byte data into a 1 byte space, but why is the output 0??
...
void test(int p1[10], int p2) {
int l1;
int l2[10];
printf("params are at %d and %d\n", &p1, &p2);
printf("locals are at %d and %d\n", &l1, &l2[0]);
}
int main(void) {
test(5, 10);
}
I'm a bit confused by the code above... how can we supply an argument of 5 to the test function when the function has already speci...
Hi,
I wanted to know where does SYMBOL TABLE reside. Is it in .obj files or an .exe file?
Thanks in advance.
...
Is it legal to call a C compiler written in C or a PHP interpreter written in PHP metacircular? Is this definition valid only for languages of a specific type, like Lisp? In short, what are the conditions that an interpreter should satisfy for being called Metacircular?
...
for example int = x;
because int is 4 bytes they would take up 4 memory locations
x
x
x
x
...
When I compiled the following code, it shows that y and the beginning of the array are 60 units apart. But according to my calculation, it should have been 4 * 10 (for the array) + 4 (for k) + 4 (for y) = 48.
Also array[12] = 17 was assigned to element 12, since there's no element 12, the implementation should have gone to y and overwri...
The follow code generates y is the answer, but i've never assigned 42 to y, how could y be 42?
#include <stdio.h>
void doit2(void)
{
int x;
int y;
if (x == 42)
{
printf("x is the answer\n");
}
else if (y == 42)
{
printf("y is the answer\n");
}
else
{
printf("there is no a...
In the following code, when the line doit(x,y) is executed, what is passed to the pointer? The addresses of x and y or the values of x and y?
#include <stdio.h>
int doit(int x[], int y[]) {
x = y;
x[0] = 5;
y[2] = 10;
}
int main(void) {
int x[2];
int y[2];
x[0] = 1;
x[1] = 2;
y[0] = 3;
y[1] = 4;
doit(x,...
I wrote a program in C which has a function that processes files which can be passed to it by a file pointer.
void process_my_file(FILE *fptr, ...) {
/* do work */
}
I would like to read some input from standard input and pass it to my function, without having to write the input to a temporary file. Would it be possible to pass it ...
how do we print a number that's greater than 2^32-1 with int and float? (is it even possible?)
...
I am trying to convert from any base to base 10. For an input of 010111 base 2 it gives me 1, and for 35 base 9 it gives me 18 which should be 38. Any suggestions?
#include<stdio.h>
#include<math.h>
#include<string.h>
#define LENGTH 6
double pow( double x, double power );
int main()
{
char input[LENGTH+1] ;
int base;
unsi...
Anyone got anything about reading a sequential number from text file per line and parsing it to an array in C?
What I have in a file:
12 3 45 6 7 8
3 5 6 7
7 0 -1 4 5
What I want in my program:
array1[] = {12, 3, 45, 6, 7, 8};
array2[] = {3, 5, 6, 7};
array3[] = {7, 0, -1, 4, 5};
I've been through several ways to read it, but the ...
Lets say we have an array of char pointers
char* array[] = { "abc", "def" };
Now what should be put in the end ?
char* array[] = { "abc", "def", '\0' };
or
char* array[] = { "abc", "def", "\0" };
Though, both works. We only have to put the condition to check the end accordingly
like
array[ index ] != '\0';
or
array[ index ]...