[Solved] Why is it not compiling in Dev C++

[ad_1] This could be that the compiler is not seeing the included header file. for statement #include <conio.h> make sure your conio.h header file is in your compilers directory. else you can use #include “conio.h” and place the header file conio.h in the current project directory. This header declares several useful library functions for performing … Read more

[Solved] File Handling Operations in c

[ad_1] The array is better declared and allocated like this: char **lineArray;. lineArray = (char **)malloc(sizeof(char *) * (lineCount-1)); strtok take a string as second argument. Replace const char j=’ ‘; by const char *j=” “; Get rid of the first strtok: lineArray[p]=malloc(strlen(line));//1st bunch of memory allocated strcpy(lineArray[p],line); printf(“%s\n”,lineArray[p]); //token = strtok(lineArray[p],j); //printf(“%s\n”,token); //serialno[p]=atoi(token); //printf(“%d\n”,serialno[p]); … Read more

[Solved] Reading a specific column from a text file in C# [closed]

[ad_1] You haven’t given much details on the format of the file. Just to get you started, you can try something like(using System.Text.RegularExpressions): File.ReadLines(“path”).Sum( line => int.Parse(Regex.Match(line, @”Hours:\s(\d+)”).Groups[1].Value)) [ad_2] solved Reading a specific column from a text file in C# [closed]

[Solved] Optimizing foreach loop that compares multiple things [duplicate]

[ad_1] If you have a IEnumberable of KeyValuePairs then you could do something like this: public bool AreAllSame(IEnumberable<KeyValuePair<Int64, MyObject>> list) { return list.Select(kv => kv.Value).Distinct().Count == 1; } Not sure whether it’s really optimized but, it’s shorter! :-] Of course, whatever you’re comparing will need to be comparable. 2 [ad_2] solved Optimizing foreach loop that … Read more

[Solved] Compile c/c++ program using gcc [closed]

[ad_1] You should compile with g++, not gcc because it’s C compiler and <vector> is a C++ header file (not mentioning <vecotr> which is a typo) If you have to use C compiler, you have to remove all C++ dependencies from header files which are included from the C sources. [ad_2] solved Compile c/c++ program … Read more

[Solved] Why is this wrong? C++ Analysing Date and Time

[ad_1] This is probably what you want: if(pos != string::npos) { mystring = mystring.erase(0, 13); int z = 0; for(int i = 0; i < mystring.Length(); i++) { if(isalpha(mystring[i])) z++; } if((int)mystring[0]-‘0’ > 3) z++; //(int)mystring[0]-‘0’ converts it to int. if((int)mystring[3]-‘0’ > 1) z++; if(mystring[6] != ‘2’) z++; //No conversion needed for != if(mystring[7] != … Read more

[Solved] The order of destructor

[ad_1] The first Ghost is the PacMan member blinky. About the last order: Destroying pm1 exectutes ~PacMan(){ if (inky!= NULL) delete inky; cout <<“~PacMan()” << endl; } and then blinky is deleted too. If you want the opposite order, you’ve to write it here. [ad_2] solved The order of destructor