[Solved] Compare char array [closed]

[ad_1] Assuming that CDdata[i].artist and search are char* or const char*, all you’re currently doing is comparing the pointers not the values. You need to use something like if (strcmp(CDdata[i].artist, search)) which will return 0 for equality. strcmp is a standard function in the C standard library. [ad_2] solved Compare char array [closed]

[Solved] SQL server remove space before value when I insert data

[ad_1] Of course any kind of problems surface when you use string concatenation to build command text. In your case you have inadvertently added a space before your control values. If you had used a parameterized query this problem would not have arisen SqlCommand cmd1 = new SqlCommand(“INSERT INTO [Contracts].[dbo].[Contract] ” + “([Contract_Id],[Name],[Description],[Contracted_by],[Vendor_Name],[Related_Dept],” + “[Start_date],[Expiration_Date],[TypeofContract],[Contact_Person],” … Read more

[Solved] Regular expressions : how to find [closed]

[ad_1] The regex itself, while ugly and inefficient, should work. You do need to assign the string you’re adding into the regex before building the regex, though. While we’re at it, let’s clean it up: string tmprect = “gg_rct_MyReg1″; Regex regexObj = new Regex(@”^\s*set\s+” + tmprect + @”\s*=\s*Rect\s*\(\s*([^,\s]*)\s*,\s*([^,\s]*)\s*,\s*([^,\s]*)\s*,\s*([^)\s]*)\s*\).*$”); ([^,\s]*) matches any number of characters except … Read more

[Solved] Is *a++ = *b++ = 0 safe

[ad_1] In C and C++ you need to consider the possibility that a == b, which would certainly render it unsafe. And in C++ you also need to exclude the possibility that a and b refer to the same name, i.e. that at least one is a reference. But excluding that, and assuming *a and … Read more

[Solved] comparing five integers with if , else if statement

[ad_1] try this : int main () { int n1, n2, n3, n4, n5, biggest,smallest; cout << “Enter the five numbers: “; cin >> n1 >> n2 >> n3 >> n4 >> n5 ; smallest=biggest=n1; if(n2>biggest){ biggest=n2; } if(n2<smallest){ smallest=n2; } if(n3>biggest){ biggest=n3; } if(n3<smallest){ smallest=n3; } if(n4>biggest){ biggest=n4; } if(n4<smallest){ smallest=n4; } if(n5>biggest){ biggest=n5; … Read more

[Solved] What’s the difference between the given two codes. One gives time limit exceeded when run on ideone and the other works fine [closed]

[ad_1] What’s the difference between the given two codes. One gives time limit exceeded when run on ideone and the other works fine [closed] [ad_2] solved What’s the difference between the given two codes. One gives time limit exceeded when run on ideone and the other works fine [closed]

[Solved] C# sorts range of elements in descending order

[ad_1] Using System.Linq, you can Take the first two items, then Concat that with the rest of the list after calling Reverse: var items = new[] {1, 2, 3, 4, 5}; var sorted = items.Take(2).Concat(items.Skip(2).Reverse()); Update: You can take this logic and create a more generic implementation, such as: private static int[] SortRangeReverse(int[] input, int … Read more

[Solved] How is argv a string array when it’s a char array?

[ad_1] Your code exhibits undefined behavior because you are passing a char to a functions that expects a pointer. To print a single character you have these options, fputc(argv[0][0], stdout); putchar(argv[0][0]); // Effectively the same as above printf(“%c\n”, argv[0][0]); you can add more of printf() variants. The reason your code crashes, is because printf(argv[0][0]); is … Read more

[Solved] Object reference not set to an instance of an object Request.Browser set to null NullReferenceException [closed]

[ad_1] This code will not compile as c# will not allow you to have methods and properties that are not defined in a class/type. Really you need to have a class and that class should have a constructor and that constructor should take a Request instance as a parameter and execute a null value check … Read more

[Solved] Data Structre of Stack in C

[ad_1] When you call CreateStack, the pointer is passed by value. The pointer that is returned by the call to malloc in your function is never assigned to the STACKHEAD. Try writing a CreateStack function that returns a pointer to the stack that gets created. It should not take any arguments. 1 [ad_2] solved Data … Read more

[Solved] randomize numbers without any std- function

[ad_1] I found similar question on stackoverflow : How do I generate random numbers without rand() function? I make little modifications for generating between 0-35 and final solution: #include<stdio.h> #include<time.h> int main() { int num = 36; time_t sec; sec=time(NULL); for(;;) { sec=sec%3600; if(num>=sec) { printf(“%ld\n”,sec); break; } sec=sec%num; } return 0; } Here we … Read more

[Solved] “Member Mapping specified is not valid” error when saving to a database with Entity Framework

[ad_1] The error message is pretty clear: The type ‘Edm.String’ of member ‘SEJ_STARDATE’ in type ‘HotelSearch.APP_SEJOUR’ is not compatible with ‘SqlServer.date Change edm.String to a recognizable datetime format (MM/DD/YYYY) by manipulating its contents or using DateTime.Parse [ad_2] solved “Member Mapping specified is not valid” error when saving to a database with Entity Framework

[Solved] multiple if statements in c for beginners [closed]

[ad_1] You are not following general if-else block property if(a==1 && b<=8) // This is independent if 1 { printf(“you”); } Then this is another if-else either of if or else in this block will get executed independently of what has previously happened if(a==2 && 5<b && b<=10) // This is independent if-else block 2 … Read more