[Solved] Use String.Format with local variables C# [closed]

[ad_1] Well, first, this is not the way to get the path to the desktop directory. Instead, just do this: Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) Unlike your solution, this will work with folder redirection, remote profiles, as well as with future (and past!) Windows versions. Not to mention that Environment.Username isn’t necessarily the correct folder name anyway 🙂 Second, … Read more

[Solved] How to connect to SQL Server database file in my solution [closed]

[ad_1] Figured it out. I was being an idiot and not escaping the ‘\’ before the v11.0. Thanks all! openCon = new SqlConnection(“Data Source=(LocalDB)\\v11.0;” + “AttachDbFilename=” + AppDomain.CurrentDomain.BaseDirectory + “Encounter.mdf;” + “Integrated Security=True”); [ad_2] solved How to connect to SQL Server database file in my solution [closed]

[Solved] Processing Input file in c

[ad_1] I am unsure what problems you are having exactly but I can see the following errors in the code: In the initialise_list() function the for loop will be iterating too many times and going beyond the bounds the of array: for(int i = 0; i < sizeof(list); i++) { as sizeof(list) will return the … Read more

[Solved] Pointer will randomly print it’s address instead of it’s pointed value, C++

[ad_1] void setvalores(int vi, int fu, int ve) { velocidad = &ve; vida = &vi; fuerza = &fu; }; The pointers to vi, fu, and ve get invalidated when the function returns. You’re not seeing addresses being printed, but simply garbage. Your entire design doesn’t and shouldn’t need to use pointers though. 8 [ad_2] solved … Read more

[Solved] Switch statements for a Menu (c#)

[ad_1] As I said in the comments, you could embed it in a while loop bool continue = true; while (continue) { Console.WriteLine(“Enter Customer Details (s)”); Console.WriteLine(“Enter usage data (u)”); Console.WriteLine(“Display usage data (d)”); Console.WriteLine(“Exit (e)”); string menu = Console.ReadLine(); switch (menu) { case “s”: //statement break; case “u”: //statement break; case “d”: //statement break; … Read more

[Solved] Serialize List using Json.net

[ad_1] Serializing a List<LinkedListNode<string>> is a bit of an odd thing to do – normally one would just serialize the underlying linked list. Perhaps you’re trying to serialize a table that gives the nodes in a different order than the underlying list? If that’s the case, it might appear that one could serialize the node … Read more

[Solved] Enum and strings

[ad_1] Try the following approach #include <stdio.h> #include <string.h> int main(void) { enum Animal { cat, dog, elephant }; char * animal_name[] = { “cat”, “dog”, “elephant” }; enum Animal b; size_t n; char s[100]; fgets( s , sizeof( s ), stdin ); n = strlen( s ); if ( s[n – 1] == ‘\n’ … Read more