C

22K

Solutions

13K

Contributors

C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.

Share tech news, updates, or what's on your mind.

Sign up to Post

Dear experts,

Can anyone point to any online site which can has c/c++/Python programs written/used for Financial Engineering.

The idea is show the content/calculations involved in Financial Engineering to my tutor who can then teach me leading to building my fundamentals.

My tutors teaches for Engineering college students and may not have the orientation of Financial Engineering programming features/calculations.

Kindly guide.

Thank you
0
Get your problem seen by more experts
LVL 12
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Downloaded a Sample App.  I am using VS2015.  The app doesn't compile.  I am receiving what seems to be a REST error.

CS1503      Argument 2: cannot convert from 'System.Action<System.IO.Stream>' to 'byte[]'      Tradovate.Services      

The error is occurring at

                request.AddFile(param.Value.Name.ToString(), param.Value.Writer,
                                param.Value.FileName.ToString(), param.Value.ContentType.ToString());

In the below code.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using System.Linq;
using System.Net;
using System.Text;
using Newtonsoft.Json;
using RestSharp;

namespace Tradovate.Services.Client
{
    /// <summary>
    /// API client is mainly responsible for making the HTTP call to the API backend.
    /// </summary>
    public partial class ApiClient
    {
        private JsonSerializerSettings serializerSettings = new JsonSerializerSettings
        {
            ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
        };

        /// <summary>
        /// Allows for extending request processing for <see cref="ApiClient"/> generated code.
        /// </summary>
        /// <param name="request">The RestSharp request object</param>
        partial void InterceptRequest(IRestRequest request);

        /// <summary>
        /// Allows for extending response processing for <see

Open in new window

0
I'm following the example on https://docs.microsoft.com/en-gb/visualstudio/test/walkthrough-creating-and-running-unit-tests-for-managed-code
to learn about unit testing.
When I add the reference to Bank.sln I'm getting a message:

A reference to D:\Documents\UnitTesting\Bank\Bank.sln could not be added.  Please make sure that the file is accessible, and that it is a valid assembly or COM component.
Could it be because Visual Studio 2017 is installed on my C drive and this project is on my D drive?  I'm using C#.net
0
Dear experts,

Can some experts please refer a url for downloading 'dec-c++'.
It could be either a paid or a free version.

I am learner of C/c++ program, so i am happy to go with minimum cost to start the process with.

Thank you
0
Hello everyone

I have this program:

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
main(){
    FILE *f1;
    FILE *f2;

    f1 = fopen("pvt.txt","r");
    f2 = fopen("second.txt","w");

     int i,j;
     float v[9][6],vdr[9][6],edr[9][6],v0[9][6]; //V
     float p[9]={10,50,100,200,300,400,500,600,800}; //Pressure
     float T[6]={200,400,600,800,1000,1200}; //Temperature
     float a,b,Pcr=22060,Tcr=647.1,R=0.4615,diff;


     a=27*0.4615*0.4615*647.1*647.1/(64*22060.0);
     b=0.4615*647.1/(8*22060.0);


    //                  //

    /*Read input file for v from steam table*/
     for(i=0;i<=8;i=i+1)
       fscanf(f1,"%f %f %f %f %f %f",&v[i][0],&v[i][1],
            &v[i][2],&v[i][3],&v[i][4],&v[i][5]);


    /*Write v steam table to output file*/
    fprintf(f2, "The V Steam Values = \n");
     for(i=0;i<=8;i=i+1)
       fprintf(f2,"%f %f %f %f %f %f \n",v[i][0],v[i][1],
            v[i][2],v[i][3],v[i][4],v[i][5]);

            //          //
            for(i=0;i<=8;i=i+1)
                        for(j=0;j<=5;++j)

                            while(diff>0.001)
                            {
                            v[i][j]=v0[i][j];
                            v[i][j]=b+0.4615*(T[j]+273.15)/(p[j]+a)/(v0[i][j]*v0[i][j]);
                            diff=fabs(v[i][j]-v0[i][j])/v0[i][j];
       }
/*Write v using VDR to output file*/
        fprintf(f2, "The V using VDR Values = \n");
     for(i=0;i<=8;i=i+1)
       fprintf(f2,"%f %f %f %f %f %f

Open in new window

0
Suppose the length of array is dynamic and the elements follow the same pattern where by the next element is half the previous element. For example
1024, 512, 256, 128...

Open in new window


I would like to directly determine the index of an element. For example if I have
512

Open in new window

I would output index
1

Open in new window

without looping through the elements and comparing them with 512 then output 1. i.e not like this:

for (int i = 0;  i < length;  ++i) {
    if (array[i] == 512) { 
        printf("%d\n", i);
        break;
    }
}

Open in new window


I have been thinking of using modulus or bit manipulation like shifts but I can't get it to work. How can this be achieved?
0
Dear experts

I am a beginner in any programming language. I am currently learning C.

I have managed to write a code in bits and pieces to achieve the following

Model 1:

AAASAAA
AASSSAA
ASSSSSA
SSSSSSS
ASSSSSA
AASSSAA
AAASAAA


Model 2

AAAAAA
AASSAA
ASSSSA
AASSAA
AAAAAA


My code

#include<stdio.h>
#include<math.h>
main()
{
      int r,c;
      for(r=3;r>=1;r--)
      {
            for(c=1;c<=r;c++)
            {
                  printf(" A");
            }
            for(c=3-r;c>=1;c--)
            {
                  printf(" S");
            }
                        for(c=3-r;c>=1;c--)
            {
                  printf(" S");
            }
            for(c=1;c<=r;c++)
            {
                  printf(" A");
            }
            
      printf(" \n");      
      }
      
}


Can anyone please update my code.

Thank you
0
Prevent color change when vim is invoked.

My computer is running Windows 10 Pro 64-bit.  I connect to remote Linux Machine using telnet utility.

My shell is bash.  My terminal emulator screen has black background and white foreground.  I invoke vim <filename>.  I exit vim and return to
my terminal.  Now the terminal has changed colors.  man vim doesn't have color option that will tell me how to disable color when vim is inovked.
0
I have a commercial .exe file which can communicate and analyze data with my instrument. However, upon running, it says it wants some functions for communicating with the instrument (functions of a driver). I have got .dll folder and library folder which contains these functions. Now how do I add these function capability into the .exe.

I need to run this in windows 2000. I have installed visual basic 6.0 also. But dont know what to do next. Any help is greatly appreciated. I need to go a long way in this project and this is the first step. please.....

The picture shows the Mil dll it is asking for
0
I have to modify a Qt Creator project on Windows 7. The compiler/linker uses Visual Studio 2010 Pro SP1. (The debugger works on VS, but not on Qt.)
I debug by adding print statements. I want to be able to debug using a debugger.

I found this page which also leads to subsequent links.
http://doc.qt.io/qtcreator/creator-debugger-engines.html

The IT department (one person) is overworked, and this debugger task is considered low priority. Furthermore, the admin has no idea how to get the debugger to work. The lead said that if I can come up with a step-by-step written list of things to do, then he would raise the priority of getting the debugger to work. Statements like "add <...> to Qt screen <...>" doesn't help since IT won't know what to do. Need detailed steps.

Maybe someone has already done this and can provide these detailed steps (supported by links so I can review and ask questions, to help clarify the steps - I get one shot to get this to work). General comments and links without the detailed steps probably won't help the IT guy.

A year ago, I think I saw that we needed a version of SDK (maybe SDK 7.1?) to get the Qt Debugger to work. This SDK is not installed on my Windows 7 workstation, but I am told that we are allowed to install it. In general, we have a list of items we are allowed to install, and anything not on the list is not permitted.

My environment:
Windows 7
Qt Creator 2.6.0 based on Qt 4.8.2
Qt Compiler/linker used is hooked to Visual …
0
Making Bulk Changes to Active Directory
LVL 8
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

I am a newbie in the data structure, I have read the implementation of stack using a simple array, the algorithm for this implementation is below:-

 Stack Operations using Array

A stack can be implemented using array as follows...

Before implementing actual operations, first follow the below steps to create an empty stack.

Step 1: Include all the header files which are used in the program and define a constant 'SIZE' with specific value.

Step 2: Declare all the functions used in stack implementation.

Step 3: Create a one dimensional array with fixed size (int stack[SIZE])

Step 4: Define a integer variable 'top' and initialize with '-1'. (int top = -1)

Step 5: In main method display menu with list of operations and make suitable function calls to perform operation selected by the user on the stack.

push(value) - Inserting value into the stack

In a stack, push() is a function used to insert an element into the stack. In a stack, the new element is always inserted at top position. Push function takes one integer value as parameter and inserts that value into the stack. We can use the following steps to push an element on to the stack...

Step 1: Check whether stack is FULL. (top == SIZE-1)

Step 2: If it is FULL, then display "Stack is FULL!!! Insertion is not possible!!!" and terminate the function.

Step 3: If it is NOT FULL, then increment top value by one (top++) and set stack[top] to value (stack[top] = value).

pop() -
0
I have found this below function for deleting a node from Linked List from the book named [DATA STRUCTURE AND ALGORITHMS MADE EASY](https://www.amazon.in/Data-Structures-Algorithms-Made-Easy-ebook/dp/B01N4OA309?tag=googinhydr18418-21)


The code is:-
void DeleteFromLinkedList(struct ListNode **head, int position){
int k=1;
struct ListNode *p, *q;
if(*head==NULL){
printf("List Empty");
return;
}
p=*head;
//from the beginning
if(position==1){
*head=(*head)->next;
free(p);
return;
}

else{
//Traverse the list until arriving at the position from which we want to delete
while((p!=NULL) && (k<position)){
k++;
q=p;
p=p->next;
}
if(p==NULL) //At the end
printf("Position does not exist");
else{  //From the middle
q->next=p->next;
free(p);
}
}
}

Open in new window


Now my question is what is the meaning of
(k<position)

Open in new window

here what is the purpose of using this
 (k<position)

Open in new window

and wh at is the use of
intk=1;

Open in new window


please explain me in detail the above code.
0
I am a newbie to data structure I have done the following code for `Insertion` and `Deletion` operation with an array, it runs without error but there is a runtime error plz help me to find out the error.

 
    #include <stdio.h>
    
    #define MAX 5
    
    
        void insert(int *,int pos, int num);
        void del(int *,int pos);
        void display(int *);
       
    
            int main()
            {
    
                int arr[5];
    
    
    
                /*Start of array insertion function*/
                    insert(arr,1,11);
                    insert(arr,2,12);
                    insert(arr,3,13);
                    insert(arr,4,14);
                    insert(arr,5,15);
                /*End of array insertion function*/
    
                printf("Elements of Array:\n"); /*printing aray elements after insertion*/
                    display(arr); /*display funtion called for printing array elements*/
    
                /*Start of deletion of array function*/
                    del(arr,5);
                    del(arr,2);
                /*End of deletion of array function*/
    
                printf("After deletion of array:\n");/*printing array elements after deletion*/
                    display(arr);/*display function called for printing array element*/
    
               
    
    
                return 0;
    
            }
    
            /*inserts an element num at given position pos*/
                void 

Open in new window

0
Hi. I am new to pointer I have done the following programme using pointer with array

#include<stdio.h>
void disp(int *);
void show(int a);

int main()
{
    int i;
    int marks[]={55,65,75,56,78,78,90};
    for(i=0;i<6;i++)
        disp(&marks[i]);
    return 0;
}
void disp(int *n)
{
    show((int) &n);
}
void show(int a)
{
    printf("%d",*(&a));
}

Open in new window


I am sending the address of n to the function show from the function disp and in the function show I want to print the values that is stored in the address n but in this program output is the address. What is wrong in the programme?
0
Hello!!!!


How to convert this;

std::string response;
char time[13];

...

response.copy(time, 13,223);
time[13] = '\0';
printf("%s\n" ,time); // this print value:1517691086218

       ????   //how to convert char time[13] to int ?

       if (time == 1517691086218){
	printf("OK %d\n" ,time);
	} else {
	printf("NOT\n %d\n" ,time);
	}

Open in new window



How to convert;

char time[13] = '1517691086218'

to

int value = 1517691086218

?

Thanks...
0
Hi, I've always used CURL, but I was forced to use sockets this time for some reason. This is my code;

#include "stdafx.h"
#include <winsock2.h>
#include <string>
#include <iostream>
using namespace std;

void HTTPReq(
    const char* verb,
    const char* hostname,
    int port,
    const char* resource,
    const char* opt_urlencoded,
    string& response)
{
    WSADATA wsaData;
    if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0)
    {
        cout << "WSAStartup failed.\n";
        exit(1);
    }

    SOCKET Socket = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);

    struct hostent *host;
    host = gethostbyname(hostname);

    SOCKADDR_IN SockAddr;
    SockAddr.sin_port=htons(port);
    SockAddr.sin_family=AF_INET;
    SockAddr.sin_addr.s_addr = *((unsigned long*)host->h_addr);

    if (connect(Socket,(SOCKADDR*)(&SockAddr),sizeof(SockAddr)) != 0)
    {
        exit(1);
    }

    // Build request
    string req = verb; // GET | POST
    req.append(" ");
    // Note, on GET, 'resource' must contain the encoded parameters, if any:
    req.append(resource);
    req.append(" HTTP/1.1\r\n");

    req.append("Host: ");
    req.append(hostname);
    req.append(":");
    req.append(to_string(static_cast<long long>(port)));
    req.append("\r\n");

    if (strcmp(verb, "POST") == 0)
    {
        req.append("Cache-Control: no-cache\r\n");
        req.append("Content-length: ");
        req.append(to_string(static_cast<long long>(strlen(opt_urlencoded))));
        

Open in new window

0
When i executed below code why i am getting '?' for the first case as i know for codepage 932, which also support line draw characters How this API deals with codepages , AFAIK it search and map the character in the codepage then returns position of character from the codepage.

    typedef struct dbcs {
    unsigned char HighByte;
    unsigned char LowByte;
    } DBCS;

static DBCS set[5] = {0x25,0x5D};
unsigned char array[2];

#include <windows.h>
#include <stdio.h>

int main()
{
   // printf("hello world");
    int str_size;
    LPCWSTR                 charpntr;
    LPSTR                   getcd;
    LPBOOL                  flg;
int i ;
array[0] = set[0].LowByte;
array[1] = set[0].HighByte;
charpntr = &array;
str_size = WideCharToMultiByte(932, 0, charpntr, 1, getcd, 2, NULL,NULL);
printf(" value of %u",getcd);
printf("number of bytes %d character is  %s",str_size,getcd);
printf("\n");


array[0] = set[0].LowByte;
array[1] = set[0].HighByte;
charpntr = &array;
str_size = WideCharToMultiByte(437, 0, charpntr, 1, getcd, 2, NULL,NULL);
printf(" value of %u",getcd);
printf("number of bytes %d character is  %s",str_size,getcd);
printf("\n");

}

Open in new window

Untitled.png
0
Hi, I am able to write the query and joined that with JAVA Code and it working fine. Now I Would like to highlight few items from the spreadsheet in the Final Outlook mail notification as below Please share your thoughts!!

This final mail output data can be captured from the spreadsheet and print. Kindly do the needful ASAP!!!

REGISTRATION TRANSACTIONS

CUSTOMER ID                SUCCESS(10) ERROR(10) PENDING(10)
CUSTOMER ID                SUCCESS(10) ERROR(10) PENDING(10)[/i]
0
My large 'C' language code is in Linux Server.

Which Linux Editor should I use to edit and navigate my source code?

I need to use powerful editor that has powerful source code navigation.  For example, from function call, one keystroke will navigate to function definition.  From 'C' source file, one keystroke will open the include file.

There should be comprehensive information to  learn the editor from book or other sources.

From windows computer, I telnet to Linux Server.  

The folder structure that contains my source code is in my home directory.
0
Improve Your Query Performance Tuning
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

Hi,

Can someone please give me a link to a book on KCML Kerridge C Macro Language (KCML) and any info on how to develop in it please.

Started working for a company that uses it - thanks!
0
Hi all,
I am comletely new in c programing,
I have a server client program in c , that I use thread in it,
Client send a sentence and server convert it to upper case and send to client,
My question is:
How can in server find which client connect to server, for example :
If a request receive from client 1 ,server send hello client 1 , and for client 2, it send hello client 2, and etc,

Very thanks for your helps,

My code is
Thanks dear,
My code in server is :
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <stdlib.h>

int main(){
  int welcomeSocket, newSocket, portNum, clientLen, nBytes;
  char buffer[1024];
  struct sockaddr_in serverAddr;
  struct sockaddr_storage serverStorage;
  socklen_t addr_size;
  int i;

  welcomeSocket = socket(PF_INET, SOCK_STREAM, 0);

  portNum = 7891;
  
  serverAddr.sin_family = AF_INET;
  serverAddr.sin_port = htons(portNum);
  serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
  memset(serverAddr.sin_zero, '\0', sizeof serverAddr.sin_zero);  

  bind(welcomeSocket, (struct sockaddr *) &serverAddr, sizeof(serverAddr));

  if(listen(welcomeSocket,5)==0)
    printf("Listening\n");
  else
    printf("Error\n");

  addr_size = sizeof serverStorage;

  /*loop to keep accepting new connections*/
  while(1){
    newSocket = accept(welcomeSocket, (struct sockaddr *) &serverStorage, &addr_size);
    /*fork a child process to handle the new connection*/
    if(!fork()){
      nBytes =

Open in new window

0
Dear all,

I have an open code of MFC made in 2002. Could someone please tell me approximately which is the version of this script?

I imagine it is Microsoft C or Microsoft C++, but which version if was compiled in 2002?

Thanks

mfc.jpg
0
I migrated an SSD to a larger SSD using Macrium Reflect.   Now there is a large amount of unallocated space on the larger SSD.   How can I expand the C volume to use this space?
0
Can we make our keyboard into a mini piano by using c language
0
Somewhere along the line, about when OOP came along, I was diverted into doing other things.  So, I lack the "cultural refinement" that must have come along with it.
I've written programs in C, C++, VBA, C#, and Fortran (of whatever recent vintage) but, I must admit, quit in starting on C# because there were all those class names that had no meaning for me.  I couldn't even debug an example program as a result!

I think I understand the general concepts - so that's not it.
It's the specifics that are elusive.
I've seen the same thing in VBA but seem to have been able to get things done.  It was sort of like "programming by example" as in "copy & paste".

I've researched it a bit but don't seem to find the answer.  So:
What is the key to understanding the Classes, what they're called and what they do, so that one can be relatively productive?  Does this come by osmosis?
It must be something like a dictionary....
Or, if the proper term is other than "Classes", can you enlighten me a bit please?
0

C

22K

Solutions

13K

Contributors

C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, so it has found lasting use in applications that had formerly been coded in assembly language, including operating systems as well as various application software for computers ranging from supercomputers to embedded systems. It is distinct from C++ (which has its roots in C) and C#, and many later languages have borrowed directly or indirectly from C.