[Solved] speeding vector push_back [closed]

Indeed push_back may trigger reallocation, which is a slow process. It will not do so on every single push_back though, instead it will reserve exponentially more memory each time, so explicit reserve only makes sense if you have a good approximation of resulting vector size beforehand. In other words, std::vector already takes care of what … Read more

[Solved] How can I merge this two bits of code [closed]

Do you want something like this? genOutList= ( from i in genOutList where !genAccList.Any(x=>x.Contract==i.Contract) select i ).ToList(); Or genOutList.RemoveAll(x=>genAccList.Any(i=>i.Contract==x.Contract)); 0 solved How can I merge this two bits of code [closed]

[Solved] Setting variable types from CSV

Right… Because you can never know what the input will be from the CSV you can’t always try and implicitly convert the string to a DateTime and because you want to do the convert of a string within the select a way to do this is an extension method. public static class StringExtensions { public … Read more

[Solved] How can I add closed tag in xml document?

Document containing unclosed tag is not XML at all. As others suggested in comments, ideally the effort to fix this problem is done by the party that generate the document. Regarding the original question, detecting unclosed tag in general isn’t a trivial task. I would suggest to try HtmlAgilityPack (HAP). It has built in functionality … Read more

[Solved] Configuring log4net to write on a database

You need to create the database and the Log table yourself. If you want to diagnose possible issues with log4net, you can create a diagnostic trace by adding this to your .config file: <system.diagnostics> <trace autoflush=”true”> <listeners> <add name=”textWriterTraceListener” type=”System.Diagnostics.TextWriterTraceListener” initializeData=”C:\whatever\your\path\is\log4net.txt” /> </listeners> </trace> </system.diagnostics> and adding the debug switch: <appSettings> <add key=”log4net.Internal.Debug” value=”true”/> </appSettings> … Read more

[Solved] I need to find the file path and file name of a file that matches the string lastline [closed]

try { string lastline = “Controller”; // assuming you know the file your searching for foreach (string filePaths in Directory.GetDirectories(@”E:\Program Files (x86)\foobar2000\library\”)) { foreach (string f in Directory.GetFiles(filePaths, “*” + lastline + “*.*”)) { Console.WriteLine(f); // would print the filepath n the file name } } } catch (Exception ex) { Console.WriteLine(ex.Message); } Hope this … Read more

[Solved] Solving with only loop

public static int smallest(int n) { int i = 1; for (; ; ) { int contain = 0; int temp = 0; int myNum = 0; for (int j = 1; j <= n; j++) { myNum = i * j; temp = myNum; while (true) { if (temp % 10 == 2) { … Read more

[Solved] Using scanf funciton in printf to get values

scanf() returns number of receiving arguments successfully assigned or EOF in case of failure. Read more about scanf() here. In context of your program, when you give input 5 the scanf() successfully assign it to receiving argument i and since the receiving argument is 1, scanf() is returning 1 which is getting printed. Hence you … Read more

[Solved] Why is my Parcelable Creator not working?

return new Set(parcel.ReadStringArray(), parcel.ReadBooleanArray()… At parcel.ReadBooleanArray() You have no boolean arrays in the constructor public Set ( string[] Jugador, int[] Games, int[] NoForzados, int[] Aces, int[] Winners, int[] DobleFaltas, int[] Primeros, int[] PrimerosGanados, int[] Segundos, int[] SegundosGanados) Did you forget to set jugado? 1 solved Why is my Parcelable Creator not working?

[Solved] C++ Return the reference of an array [duplicate]

Is this answer correct? It is a declaration of a function that returns reference to an array of 10 int. gdb tells me it returns a int * variable. No it doesn’t. It tells you that the variable t that you created is an int * variable. 0 solved C++ Return the reference of an … Read more

[Solved] In ASP.NET MVC2, convert time user’s timezone. How to get timezone info? [closed]

You’re passing values that aren’t even of the right data type. Read up on TimeZoneInfo so you know how to use it properly. Also read: Why you shouldn’t use DateTime.Now The timezone tag wiki DST and Time Zone Best Practices Also understand that somewhere here you actually have to know the user’s time zone. Just … Read more

[Solved] how to represent number bigger than long in c [duplicate]

Use integer type long long. It is good for at least the range -9223372036854775807 <= x <= +9223372036854775807. #include <stdio.h> int main(int argc, char *argv[]) { long long big = 600851475143; printf(“%lld\n”, big); // prints 600851475143 return 0; } Alternatively, one could use int64_t or uint64_t – 64-bit types. The range mentioned above is the … Read more

[Solved] Singly Linked List – Backward in C [closed]

after you will build the fundamental function for this list you can use “for each” function to do your task: int SlistForeach(node_t from, node_t to , action_func_t action_func, void *param) { int stat = 1; node_t index = from; assert(NULL != to); assert(NULL != from); while(index != to) { stat = action_func(&(index->data), param); if(0 == … Read more

[Solved] why does the following code produce segmentation fault [duplicate]

WHere does your string point to? Nowhere! That’s why you have segmentation fault. You have to either allocate variable on stack as array or define it as pointer and later allocate memory using malloc. When using malloc, don’t forget to include “stdlib.h” Either do this: char str[6]; strcpy(str,”C-DAC”); or char *str=malloc(sizeof(*str) * 6); strcpy(str,”C-DAC”); solved … Read more