Hi All,
Is it possible to create an AST for any arbitrary programming language or IR using C or C++ alone (without the help of tools like YACC and LEX )?
If so, how to implement the lexical and syntactic analysis ?
If not, what are the tools that have to augmented to C or C++ to successfully create an AST ?
Hope I made my doubt clear...
main()
{
if (fork() || (fork() && fork()))
printf("AA\n");
else if (!fork())
printf("BB\n");
else
printf("CC\n");
}
I have run the following code and get the results AA AA CC BB CC BB.
While I understand how fork works, I don't understand what it does with logical operators. The teacher in our class wants us to ...
I am trying to write a function that prints out the elements in an array. However when I work with the arrays that are passed, I don't know how to iterate over the array.
void
print_array(int* b)
{
int sizeof_b = sizeof(b) / sizeof(b[0]);
int i;
for (i = 0; i < sizeof_b; i++)
{
printf("%d", b[i]);
}
}
What is the b...
I am trying to create a simple datastructure that will make it easy to convert back and forth between ASCII strings and Unicode strings. My issue is that the length returned by the function mbstowcs is correct but the length returned by the function wcslen, on the newly created wchar_t string, is not. Am I missing something here?
typed...
Okay, I am trying to integrate some C code into a C++ project, and have run into a few problems. I will detail the first one here.
I keep running into this error:
error: cannot convert 'char*' to 'char**' in assignment|
here is the offending code (with the breakpoint marked):
char** space_getFactionPlanet( int *nplanets, int *faction...
I am trying to write a database for class in which I read all the key values in from a file (formatted keyNULL BYTEvalueNULL BYTE etc). I amt rying to use a linked list for this, but I get the error that the struct has no next value. Please help me!
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include ...
In an earlier question, I asked about typecasting pointers, but was directed to the better solution of using the C++ allocation system instead of mallocs. (I am converting some C code to C++)
However, I still have an issue with a similar function:
I changed:
tmp = malloc(sizeof(char*) * mtmp); --> tmp = new char*[mtmp];
and
free(tm...
I'm making an application and would like to test the toString method I just made. I'm using Visual c++ 2008. Is there a way to see console output without having a console window? Such as in the Output panel?
Thanks
...
If I write a python script, anyone can simply point an editor to it and read it. But for programming written in C, one would have to use decompilers and hex tables and such. Why is that? I mean I simply can't open up the Safari web browser and look at its code.
...
I've got a C program that encounters errors when I enter a while loop.
I initialize a variable (fragmentcount) and write into it using fscanf and assign it a value of 4 (this works)
int fragmentCount;
if ((fscanf(fp, "%i", &fragmentCount)) == 1) {
...
}
However, when I try to access it in a while loop below, fragmentCount = 0
wh...
What is difference between our usual pointers(ones which we normally use), near pointers and far pointers and is there a practical usage for near and far pointers in present day C/C++ systems? Any practical scenario which necessiates use of these specific pointers and not other c,c++ semantics will be very helpful.
...
In GCC, I'm able to do this:
(CachedPath){ino}
inode->data = (struct Data)DATA_INIT;
where:
struct CachedPath
{
Ino ino;
};
typedef int8_t Depth;
struct Data
{
Offset size;
Blkno root;
Depth depth;
};
#define DATA_INIT {0, -1, 0}
MSVC gives the following error for these kind of casts:
error C2143: syntax error : m...
I have an application which links to a number of libraries, most of them are available as both static as well as dynamic library on my machine. Below is the output of the ldd command.
linux-gate.so.1 => (0xffffe000)
libssl.so.0.9.8 => /usr/lib/libssl.so.0.9.8 (0xb782c000)
libc.so.6 => /lib/libc.so.6 (0xb76cc000)
libcrypto.so.0.9.8 => /...
I am confused. As i asked the question previously about overloading in C, i got some answers.
Whenever i try to make others understand about this, i got confused in variadic functions.
Please let me know about it with your shower of knowledge!
...
Hi all,
I have a program in C that print a table. I want update the values of this table without reprint the entire table. I can update one line with \r character, but how I can update more than one line?
...
Is there a libc function (or equivalent) to know the current size of the heap?
I have a memory problem in my application, and it seems being able to monitor the heap when I want to would help me find the problem. So is there a way to know the current size of the heap?
...
Is it safe to call errno multiple times when dealing with the same error. Or is it safer to work with a local copy?
This sample illustrates my question:
// If recvfrom() fails it returns -1 and sets errno to indicate the error.
int res = recvfrom(...);
if (res < 0)
{
// Risky?
printf("Error code: %d. Error message: %s\n", errno...
Given a file, how can I get the LBA ranges corresponding to the file?
Can FSCTL_GET_RETRIEVAL_POINTERS do the job?
...
hi ,
I have implemented FTP, for downloading i am using FTPGetFile but is throwing error
"Error 87 : The Parameter is incorrect"
My code looks like :
int CFtpClient::GetFile(char* szRemoteFile, char* szLocalFile,int iType, DWORD& dwLastError )
{
dwLastError = 0;
if (m_bActiveSession)
{
if (!FtpGetFile (m_hConnec...
i.e. can printf be told to ignore zero when it precedes the decimal point?
...