|
If I don't call the movenext then pointer will be at one row and the data may overwrite.
In my requirement I want to moveprev one step and delete it.
|
|
|
|
|
Sampath579 wrote: If I don't call the movenext then pointer will be at one row and the data may overwrite. How have you verified this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I believe Jochen was spot on with his very first remark. The documentation of CRowset::MoveFirst | Microsoft Docs[^] clearly states that
Quote: Calls IRowset::RestartPosition to reposition the next-fetch location to the initial position (the position that was the next-fetch location when the rowset was created) and retrieves the initial row.
(emphasis mine)
In other words, your next Fetch would return the initial row at that time, no matter how many changes you made to the table in between the Move and the Fetch!
Looks like you should trust your error message and change your code accordingly.
P.S.: I just realized that it may still be considered ambiguous. However, you have to consider if (or why) the insertion of rows should affect the current Fetch position. The Insert command documentation does not indicate that it affects the Fetch position. If it would, shouldn't it say as much?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
It does not work. Any other way of moving to previous record. MovePrev() throwing -2147217837 error code.
I definitely need to go and get the data from MovePrev().
|
|
|
|
|
My google-fu is lacking this morning.
I'm looking for a simple green/red (pass/fail) led indicator that I can "drop" in a MFC dialog ?
Any suggestion ?
(I could bake one, but feeling lazy, and it might not look as pretty)
I'd rather be phishing!
|
|
|
|
|
Maximilien wrote: I'm looking for a simple green/red (pass/fail) led indicator that I can "drop" in a MFC dialog ?
Any suggestion ?
Just create them both (green/red led indicator icons) in the image editor!
|
|
|
|
|
|
The author's code :
An array consisting of N integers is given. There are several Right Circular Rotations of range[L..R] that we perform. After performing these rotations, we need to find element at a given index.
Quote: Input : arr[] : {1, 2, 3, 4, 5}
ranges[] = { {0, 2}, {0, 3} }
index : 1
Output : 3
Explanation : After first given rotation {0, 2}
arr[] = {3, 1, 2, 4, 5}
After second rotation {0, 3}
arr[] = {4, 3, 1, 2, 5}
After all rotations we have element 3 at given
index 1.
#include <bits/stdc++.h>
using namespace std;
int findElement(int arr[], int ranges[][2],
int rotations, int index)
{
for (int i = rotations - 1; i >= 0; i--) {
int left = ranges[i][0];
int right = ranges[i][1];
if (left <= index && right >= index) {
if (index == left)
index = right;
else
index--;
}
}
return arr[index];
}
int main()
{
int arr[] = { 1, 2, 3, 4, 5 };
int rotations = 2;
int ranges[rotations][2] = { { 0, 2 }, { 0, 3 } };
int index = 1;
cout << findElement(arr, ranges, rotations, index);
return 0;
}
Quote: and the authors logic:
Method : Efficient
We can do offline processing after saving all ranges.
Suppose, our rotate ranges are : [0..2] and [0..3]
We run through these ranges from reverse.
After range [0..3], index 0 will have the element which was on index 3.
So, we can change 0 to 3, i.e. if index = left, index will be changed to right.
After range [0..2], index 3 will remain unaffected.
So, we can make 3 cases :
If index = left, index will be changed to right.
If index is not bounds by the range, no effect of rotation.
If index is in bounds, index will have the element at index-1.
i tried buy brute fore method and it took O(n^2) time complexity. So i want to understand this logic, can someone please explain the logic.
i have edited the information given, and it concludes all the information given by the question. Below is the link to the problem.
Find element at given index after a number of rotations - GeeksforGeeks[^]
Thank you
modified 6-Aug-18 4:19am.
|
|
|
|
|
What is a "range" or a "rotate range?"
When I hear the term rotate, I envision each element in the array could move one position to the left and the element that is in position 0 now moves to the N-1 position in the array. Similarly, each element in the array could move one position to the right and the element that is in position N-1 now moves to position 0 in the array. Am I way off?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
please check the question again i have edited it and also provided with the link to the original problem
|
|
|
|
|
Please elaborate: it is not clear what you are trying to accomplish.
Note: it could be NOT necessary to actually perform the rotations, you could possibly compute the result without actually rotate the array.
|
|
|
|
|
please check again i have elaborated it and have also provided link to the original question
|
|
|
|
|
The logic is there in the code and description, maybe you need to read more of the book you are studying.
|
|
|
|
|
if you know the logic can you elaborate.
please
|
|
|
|
|
Like I said, the logic is in the code. You need to study the code and the comments to understand the logic.
|
|
|
|
|
You are not rebuilding the array to match what it would look like after all the rotations. You are looking at a single index in the array. The logic applies to what is the effect of a rotation to that index alone - not the whole array.
Socialism is the Axe Body Spray of political ideologies: It never does what it claims to do, but people too young to know better keep buying it anyway. (Glenn Reynolds)
|
|
|
|
|
hello i want basics of c programming language
|
|
|
|
|
|
|
I need to read/write small chunks of data over an unreliable communication link in an embedded system. When I was student I learned about interleavers/deinterleavers, Viterbi-encoding, Reed Solomon-encoding, etc, but that was a million years ago so I'm sure there's something better out there today. I would prefer something that is available in open source C-code and my data is not streaming so it doesn't need to support on-the-fly operations, it just need to be able to encode/decode packets of arbitrary sizes. Can someone please recommend something?
|
|
|
|
|
The old modem protocols XModem, YModem and Zmodem are designed for what you are doing they send packets with CRC checks and packets are accept or reject which causes the packet to be resent. You can net search for the code.
A simple XModem send routine looks like this which should give you an understanding of what it does
Send data of a fixed packet size, send the CRC for the packet .. wait for ACK or NAK. Resend packet on NAK.
simple xmodem/ymodem implementation in C · GitHub[^]
A full Zmodem with both send and receive implementation is more complex but once you understand the simple xmodem it should make sense. The greater complexity is because the transfer packet size auto adjusts, as you get more packet rejects it sends smaller and smaller packets. If you are getting transmission errors you don't want to waste time sending large packets over and over, expect an error and send small packets. The smaller packets means there is a lot of packet acknowledges going on but that is faster than resending large packets.
pkg-sbbs/zmodem.c at master · ftnapps/pkg-sbbs · GitHub[^]
ZMODEM - Wikipedia[^]
Ethernet protocols extend beyond that in that they allow and expect the packets to arrive out of order. The X/Y/Z modem protocols are strictly packets in order processes which is what you said was okay.
In vino veritas
modified 5-Aug-18 20:39pm.
|
|
|
|
|
A little while ago, I paid a visit to the official documentation page that covers the LTCG linkage editor command line switch, at /LTCG (Link-time Code Generation) | Microsoft Docs, which spears to me to give misleading information about where the option is set in Visual Studio. Being the good citizen that I am, I wrote it up, which gave rise to Setting LTCG in Visual Studio 2017 · Issue #376 · MicrosoftDocs/cpp-docs · GitHub. Upon visiting the generated issue page on GitHub, I added a picture of the property page where I found and set the option, to expedite linking of the release build of a project that imports a module that was compiled with the /GL switch, so that it can be used with P/Invoke.
This is not my first exposure to commenting on Microsoft documentation, and I am delighted to see this direct feedback channel. I wish there had been such a direct channel when I discovered a bug in the COBOL compiler for the IBM System/34, way back in 1980. I reported that bug, but it required writing and sending a full-blown business letter, via the United States Postal Service, and the attendant delays and labor on the IBM end of the connection.
I was further gratified to discover that, since I have an active GitHub account, I could augment the textual comment that caused the issue to be opened with a picture of my screen, captured courtesy of the ALT-Print Screen keyboard shortcut and the built-in Paint program. Yes, I still use Paint, more often than you might think.
Since I assume that adding such detail to the issue is available to me because I have an active GitHub account, I'd say this is ample reason for any serious developer to have one, even if you don't have any repositories, although I opened it because I have a handful of them.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|
Hey guys!
I have the following code and I can't seem to find a way to query my previous query because $row['name']; is not working... Here is part of my code:
<?php
$id = $_GET['id'];
if ($id) {
$sql = "SELECT * FROM forum_sub_cats WHERE id = ?;";
if(!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "i", $id);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$resultCheck = mysqli_num_rows($result);
$admin_user_level = $admin_user_level + '1';
if ($resultCheck < 1) {
echo "The forum you are trying to create a topic on, does not exist\n";
} else {
$row1 = mysqli_fetch_assoc($result);
if ($row1['admin'] == 1 && $admin_user_level == 0) {
echo "You are not an administrator, therefore you cannot post on this forum!\n";
} else {
if (!$_POST['submit']) {
echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<form method=\"POST\" action=\"./forum_main.php?act=create&id=".$id."\">\n";
echo "<tr><td>Form Sub Category</td><td><select name=\"cat\">\n";
$sql2 = "SELECT * FROM forum_cats WHERE admin < ?;";
if(!mysqli_stmt_prepare($stmt, $sql2)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "i", $admin_user_level);
mysqli_stmt_execute($stmt);
$result2 = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result2)) {
$row = $row['id'];
$sql3 = "SELECT * FROM forum_sub_cats WHERE cid = ?;";
if(!mysqli_stmt_prepare($stmt, $sql3)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "i", $row);
mysqli_stmt_execute($stmt);
$result3 = mysqli_stmt_get_result($stmt);
echo "<option value=\"0\">".$row['name']."</option>\n";
while ($row2 = mysqli_fetch_assoc($result3)) {
$selected = ($row2['id'] == $id) ? "SELECTED": "";
echo "<option value=\"".$row2['id']."\"".$selected."> ".$row2['name']."</option>\n";
}
|
|
|
|
|
unfortunately your code nothing to do with C/C++/MFC...
Maybe you will try to ask to some more appropriate forum?
|
|
|
|
|
Try to write a small program.almost forgot task sync concept, need some help.
task1:
if (cx == True)
{
do task1();
cx = False;
}
task2:
if (cx == False)
{
do task2();
cx = True;
}
Is possible the 2 tasks step in a deadlock situation?
Thanks
|
|
|
|
|