Total DevC++ Newbie..


I'm a total newbie and.. with the code above..



What I want to do is have 10 dValue numbers, but if, of those 10 I only enter 5 values, the exe shouldnt ask me to enter all 10 and just add the 5 values I entered when I press the return key .. or something like that



```
//
//    Add 3 numbers 
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    double dValue1;
    double dValue2;
    double dValue3;

    // enter three numbers
    cout << "This program adds three numbers;\n";
         
    cout << "Enter three integers:\n";

    cout << "n1 - ";
    cin  >> dValue1;

    cout << "n2 - ";
    cin  >> dValue2;

    cout << "n3 - ";
    cin  >> dValue3;

    //  the sum 
    cout << "n1 + n2 + n3 = ";
    cout << dValue1 + dValue2 + dValue3;
    cout << "\n";


    // wait until user is ready before terminating program
    // to allow the user to see the program results
    system("PAUSE");
    return 0;
```
You need to give the user the option of typing in a value that represents that there are no more values to enter. Perhaps give a prompt like:



```
Please enter a value.  Enter -999999 if you have no more values [B]:[/B]
```

As for the ten (or fewer) values, you should probably have an array and a loop instead of ten separate variable names and ten separate cin statements. So you're looking at something like this:



```
double dValue[10];
    int numEntries = 0;
    double sum = 0;
    
    while (numEntries < 10)
    {
          cout << "Enter number (-999999 to stop) : ";
          cin >> dValue[numEntries];
          // check whether dValue[numEntries] == -999999
          // if so, short-circuit the loop with the "break" command
            
          // increment numEntries
          // adjust sum
    }
```

As a side note, I picked -999999 as the value to represent no more values because



1. It's an integer, so it can be represented exactly as a double (no round-off error using == to compare).
2. It's a number that, chances are, people wouldn't actually want to add, so it's sort of "out of the way". Chances are, few people want to add -999999. If they do, they can't use this program!
A few things to try.


1. Use [Variable Tables](http://odetocode.com/Articles/365.aspx) instead -> maybe the import wizard prefers that?
2. Name your return fields.


Try using the following stored proc (untested .. just thinking out loud...)



```
CREATE PROCEDURE dbo.Foo
AS

    SET NOCOUNT ON

    DECLARE @ResultTable TABLE (SomeId INTEGER)

    INSERT INTO @ResultTable
    SELECT DISTINCT Id AS Identity -- Or u can rename this field to anything...
    FROM SomeExistingTableWhichHasAnIdentityField

GO

```

Try that and see if the wizard refreshes, now.


-- 


 Attempt #2 :)


Ok .. when the EF designer/wizard/whatever fails to figure out EXACTLY what my stored proc is suppose to be returning, I usually do the following :-


1. Make sure the stored procedure doesn't exist at all in the EF designer/context, etc. (You have a clean starting point)
2. Open up your stored procedure and `/* /*` comment out *EVERYTHING* after the procedure definition.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    /* 
    .... every thing in here is commented out 
    */
GO

```

Now ...
 3. Add a forced fake return in the stored proc, which (more or less) just *defines* the output structure/fields.


eg..



```
ALTER PROCEDURE dbo.Foo
(
    Bar1 INT,
    Bar2 TINYINT,
    ... // whatever u have as your optional input arguments //
)
AS
    SET NOCOUNT ON

    SELECT 1 AS Id, 1 AS UserId, 1 AS SomeOtherId, 
        CAST('AAA' AS NVARCHAR(350)) AS Name,
        -- etc etc etc..
    /* 
    .... every thing in here is commented out 
    */
GO

```

[and then](http://www.youtube.com/watch?v=K7luMp6lb9M) ...


4. Add this stored proc to your EF designer/wizard/etc... Now the correct fields should be 'determined' by the designer. AWESOME. Yes .. the values are all hardcoded .. but that's ok (so far).
5. Once your happy that EF is now updated right, go back to your stored proc, and remove all hardcoded SELECT (which we did in the above step). Now we remove the comments which we commented out the entire real code. So you should have your original stored proc, back.


... and now EF is updated and doesn't know we've changed the plumbing of your stored proc.


win :)


does this work for ya? Turns out If I tweked each method 



```
foreach (var dataColumn in readFields.Select(column => new DataColumn(columntypeof(string)) { AllowDBNull = true, DefaultValue = string.Empty }))
{
    csvData.Columns.Add(dataColumn);
}

```

and in the second Method I changed it to use an index rather than column name



```
for (var count = 0; count < table.Columns.Count; count++)
{
    sqlBulkCopy.ColumnMappings.Add(count, count);
}

``` Check if any of the values in the cells are null.  

If they are you need to modify your code to check for null conditions before using `ToString()`. > [[cite senthil kumar.p]]
>
> yes this is android studio project.
> 
> both input 1 and input 2 are integers.
> example:
> input1 = 1000
> input2 = 20
> 
> it will create total 50 rows and the order is 
> 0
> 20
> 40
> 60
> etc.....
> 
> 

do you need the codes as below? 
......
for (int i = input1 / input2; i >=0; i--) {
 ......
 t1v.settext("" + i * input2);
 ...... c = input()  

t = len(c)  

temp = ""  

for i in range(0,len(c)):  

    if t<3:  

        break  

    else:  

        if i in (0,1,t-2,t-1):  

            temp = temp+c[i]  

        else:  

            continue  

print(temp) (a) for digit



expression : 5n + 1

where n = no of digits

for 5 digits

no of segments required = 5(5) + 1 = 25 + 1 = 26

for 10 digits

no of segments required = 5(10) + 1 = 50 + 1 = 51

for 100 digits

no of segments required = 5(100) + 1 = 500 + 1 = 501

(b) for digit



expression : 3n + 1

where n = no of digits

for 5 digits

no of segments required = 3(5) + 1 = 15 + 1 = 16

for 10 digits

no of segments required = 3(10) + 1 = 30 + 1 = 31

for 100 digits

no of segments required = 3(100) + 1 = 300 + 1 = 301

(c) for digit



expression : 5n + 2

where n = no of digits

for 5 digits

no of segments required = 5(5) + 2 = 25 + 2 = 27

for 10 digits

no of segments required = 5(10) + 2 = 50 + 2 = 52

for 100 digits

no of segments required = 5(100) + 2 = 500 + 2 = 502 The problem is that your pair's closure must return two different types of objects: int if you ask for "con", and the next closure on the line if you ask for "crd".


Here's one possible implementation:


Use a speaker so you can come back.



```
public static Func<string, dynamic> Pair(int x, Func<string, dynamic> y)
{
    Func<string, dynamic> pair =
           (a) =>
           {
               if (a == "con") return x;
               if (a == "crd") return y;
               throw new Exception();
           };

    return pair;
}

public static void Print(Func<string, dynamic> pair)
{
    while (true)
    {
        var next = pair("crd");
        Console.WriteLine((next == null ? "-":"+") +"> " + pair("con"));
        if (next != null)
        {
            Console.WriteLine("|");
            pair = (x) => next(x);
            continue;
        }
        break;
    }
}

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```


  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

Test:



```
var pair = Pair(1,
            Pair(2,
                  Pair(3,
                        Pair(4, null))));

Print(pair);

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```

output:



```
+> 1
|
+> 2
|
+> 3
|
-> 4

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
``` In C ++ 11, the code is well defined, but may not do what you expect. Exact Effects: 21.4.5 / 2:



>  Returns: `*(begin() + pos)`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> if `pos < size()`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> , otherwise a reference to an object of type `T`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> with a value `charT()`
>   
> 
> 
> 
> 
>  (adsbygoogle = window.adsbygoogle || []).push({});
>  
>   
> 
> ; the reference value should not be changed.
> 
> 
> 



  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

So, if the string is not empty, it returns a reference to the beginning of the internal buffer. If empty, it returns a reference `char`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

with a value `0`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

whose location is implementation information. let i = `(1)/(sinx*(3 + 2cosx))*dx` = `int sinx/(sin^2x*(3 + 2cosx))*dx` = `int sinx/((1 - cos^2x)(3 + 2cosx))*dx` = `int sinx/((1 - cosx)(1 + cosx)(3 + 2cosx))*dx` put cos x = t∴ – sinx.dx = dt∴ sinx.dx = – dt ∴ i = `int (1)/((1 - t)(1 + t)(3 + 2t))*(-dt)` = `int (-1)/((1 - t)(1 + t)(3 + 2t))*dt` let `(-1)/((1 - t)(1 + t)(3 + 2t)) = "a"/(1 - t) + "b"/(1 + t) + "c"/(3 + 2t)` ∴ – 1 = a(1 + t)(3 + 2t) + b(1 - t)(3 + 2t) + c(1 - t)(1 + t)put 1 – t = 0, i.e. t = 1, we get– 1 = a(2)(5) + b(0)(5) + c(0)(2) ∴ – 1 = 10a ∴ a = `(-1)/(10)`put 1 + t = 0, i.e. t = – 1, we get– 1 = a(0)(1) + b(2)(1) + c(2)(0) ∴ – 1 = 2b ∴ b = `-(1)/(2)` put 3 + 2t = 0, i.e. t = `-(3)/(2)`, we get – 1 = `"a"(-1/2)(0) + "b"(5/2)(0) + "c"(5/2)(-1/2)` ∴ – 1 = `-(5)/(4)"c"` ∴ c = `(4)/(5)` ∴ `(-1)/((1 - t)(1 + t)(3 + 2t)) = (((-1)/(10)))/(1 - t) + ((-1/2))/(1 + t) + ((4/5))/(3 + 2t)` ∴ i = `int [(((-1)/10))/(1 - t) + ((-1/2))/(1 + t) + ((4/5))/(3 + 2t)]*dt` = `-(1)/(10) int 1/(1 - t)*dt - (1)/(2) int 1/(1 + t)*dt + (4)/(5) int 1/(3 + 2t)*dt` = `-(1)/(10) (log|1 - t|)/(-1) - (1)/(2) log | 1 + t| + 4/5 (log|3 + 2t|)/(2) + c` = `(1)/(10)log|1 - cosx| - (1)/(2)log|1 + cosx| + (2)/(5)log|3 + 2cos| + c`. the compiler will throw the following errors:  


10: error: increment of read-only variable **k**,  


12: error: **lvalue** required as increment operand.