Search Results

Search found 14 results on 1 pages for 'maulrus'.

Page 1/1 | 1 

  • Error compiling flex (the lexical analyzer)

    - by Maulrus
    I'm trying to install flex on my Windows computer. I have MSYS installed. I untar flex, ./configure it, but when I try to make it, I get this error: In file included from ccl.c:34: flexdef.h:94:19: error: regex.h: No such file or directory In file included from ccl.c:34: flexdef.h:1195: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'regex_linedir' flexdef.h:1197: error: expected ')' before '*' token flexdef.h:1198: error: expected ')' before '*' token flexdef.h:1199: error: expected ')' before '*' token flexdef.h:1200: error: expected ')' before '*' token flexdef.h:1201: error: expected ')' before '*' token flexdef.h:1202: error: expected ')' before '*' token make[2]: *** [ccl.o] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 Until recently, I've only ever installed things using an .exe, so I'm pretty confused by this. Installing bison and m4 both went smoothly, and I'm wondering why this isn't. Any ideas?

    Read the article

  • Problem with reading file line-by-line

    - by Maulrus
    I'm trying to complete an exercise to write a program that takes the following command line arguments: an input file, an output file, and an unspecified number of words. The program is to read the contents of the input file line by line, find for each word given which lines contain the word, and print the lines with their line number to the output file. Here's my code: #include <iostream> #include <fstream> #include <string> #include <sstream> using namespace std; int main(int argc, char* argv[]) { if (argc < 4) { cerr << "Error #1: not enough arguments provided\n"; return 1; } ifstream in(argv[1]); if (!in.is_open()) { cerr << "Error #2: input file could not be opened\n"; return 2; } ofstream out(argv[2]); if (!out.is_open()) { cerr << "Error #3: output file could not be opened\n"; return 3; } ostringstream oss; for (int i = 3; i < argc; ++i) { int k = 0; string temp; oss << argv[i] << ":\n\n"; while (getline(in, temp)) { ++k; unsigned x = temp.find(argv[i]); if (x != string::npos) oss << "Line #" << k << ": " << temp << endl; } } string copy = oss.str(); out << copy; in.close(); out.close(); return 0; } If I try to run that, I get the predicted output for the first word given, but any words following it aren't found. For example, for the source code above will give the following output: in: Line #1: #include <iostream> Line #2: #include <fstream> Line #3: #include <string> Line #4: #include <sstream> Line #5: using namespace std; Line #7: int main(int argc, char* argv[]) { Line #12: ifstream in(argv[1]); Line #13: if (!in.is_open()) { Line #14: cerr << "Error #2: input file could not be opened\n"; Line #22: ostringstream oss; Line #23: string temp; Line #24: for (int i = 3; i < argc; ++i) { Line #26: int k = 0; Line #28: while (getline(in, temp)) { Line #30: unsigned x = temp.find(argv[i]); Line #31: if (x != string::npos) Line #32: oss << "Line #" << k << ": " << temp << endl; Line #35: string copy = oss.str(); Line #37: in.close(); out: That is, it'll find all the instances of the first word given but not any following. What am I doing wrong here?

    Read the article

  • How does assembly language interact with something like the Internet?

    - by Maulrus
    So I was thinking about languages the other day, and it struck me that any program written in a compiled language that interacts with the Internet is then translated into assembly that has to interact with the Internet. I've just begun learning a bit of x86 assembly to help me understand C++ a bit better, and I'm baffled by how something so low-level could do something like access the Internet. I'm sure the full answer to this question is much more than would fit in a SO answer, but could somebody give me maybe a basic summary?

    Read the article

  • Are there any languages that are dynamically typed but do not allow weak typing?

    - by Maulrus
    For example, adding a (previously undeclared) int and a string in pseudocode: x = 1; y = "2"; x + y = z; I've seen strongly typed languages that would not allow adding the two types, but those are also statically typed, so it's impossible to have a situation like above. On the other hand, I've seen weakly typed languages that allow the above and are statically typed. Are there any languages that are dynamically typed but are also strongly typed as well, so that the piece of code above would not be valid?

    Read the article

  • For what reasons do some programmers vehemently hate languages where whitespace matters (e.g. Python

    - by Maulrus
    C++ is my first language, and as such I'm used to whitespace being ignored. However, I've been toying around with Python, and I don't find it too hard to get used to the whitespace rules. It seems, however, that a lot of programmers on the Internet can't get past the whitespace rules. From what I've seen, peoples' C++ programs tend to be formatted very consistently with respect to whitespace (or else it's pretty hard to read), so why do some people have such a problem with whitespace-based languages like Python?

    Read the article

  • Why doesn't this for-loop execute?

    - by Maulrus
    I'm writing a program for an exercise that will read data from a file and format it to be readable. So far, I have a bit of code that will separate a header from the data that goes under it. Here it is: int main() { ifstream in("records.txt"); ofstream out("formatted_records.txt"); vector<string> temp; vector<string> headers; for (int i = 0; getline(in,temp[i]); ++i) { static int k = -1; if (str_isalpha(temp[i])) { headers[++k] = temp[i]; temp.erase(temp.begin() + i); } else { temp[i] += "," + headers[k]; } } } (str_isalpha() is just a function that applies isalpha() to every character in a string.) Now, the for-loop in this program doesn't execute, and I can't figure out why. Does anybody know?

    Read the article

  • What are the reasons for casting a void pointer?

    - by Maulrus
    I'm learning C++ from scratch, and as such I don't have an expert understanding of C. In C++, you can't cast a void pointer to whatever, and I understand the reasons behind that. However, I know that in C, you can. What are the possible reasons for this? It just seems like it's be a huge hole in type safety, which (to me) seems like a bad thing.

    Read the article

  • Why pass by const reference instead of by value?

    - by Maulrus
    From what I understand: when you pass by value, the function makes a local copy of the passed argument and uses that; when the function ends, it goes out of scope. When you pass by const reference, the function uses a reference to the passed argument that can't be modified. I don't understand, however, why one would choose one over the other, except in a situation where an argument needs to be modified and returned. If you had a void function where nothing is getting returned, why choose one over the other?

    Read the article

  • What the reasons for/against returning 0 from main in ISO C++?

    - by Maulrus
    I know that the C++ standard says that return 0 is inserted at the end of main() if no return statement is given; however, I often see recently-written, standard-conforming C++ code that explicitly returns 0 at the end of main(). For what reasons would somebody want to explicitly return 0 if it's automatically done by the compiler?

    Read the article

  • Why does C++ allow variable length arrays that aren't dynamically allocated?

    - by Maulrus
    I'm relatively new to C++, and from the beginning it's been drilled into me that you can't do something like int x; cin >> x; int array[x]; Instead, you must use dynamic memory. However, I recently discovered that the above will compile (though I get a -pedantic warning saying it's forbidden by ISO C++). I know that it's obviously a bad idea to do it if it's not allowed by the standard, but I previously didn't even know this was possible. My question is, why does g++ allow variable length arrays that aren't dynamically allocated if it's not allowed by the standard? Also, if it's possible for the compiler to do it, why isn't it in the standard?

    Read the article

  • Could someone tell me if my C++ indent style is named? (example given)

    - by Maulrus
    I'm learning C++. For me, my programming style is just what looks the best; it doesn't seem to follow the rules of any one particular style. Here's an example void f(int x){ //no space between close-paren and bracket if (!x){ cout << "x is non-zero\n"; } //closing bracket indented to the same level as the original statement } It's only slightly different for something like a class or a namespace: class myClass {}; //space between class name and bracket, otherwise the same as functions K&R style does uses that kind of bracketing for statements, but my style uses it for everything. I'd like to know if there's a name for it so I can say simply what my indent style is without having to explain using examples like these.

    Read the article

1