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

Sonicwall site-to-site VPN speed.  We have a main site - Site A, and 2 remote sites - B & C.  Site A has internet speed of 20M/300M.  The remote sites have 10M/100M.  From site A we can only "upload" data to the remote sites at 10M.  Shouldn't we be able to push data to the remote sites at closer to the 20M upload speed of the main site?  Sonicwall support says it's limited by the slowest speed, but that doesn't make sense to me.  Are they correct?
0
The Firewall Audit Checklist
The Firewall Audit Checklist

Preparing for a firewall audit today is almost impossible.
AlgoSec, together with some of the largest global organizations and auditors, has created a checklist to follow when preparing for your firewall audit. Simplify risk mitigation while staying compliant all of the time!

From a SQL 2008R2 database, using Exlcel 2010,
I need to update the D cell (Account No)-number  by using the values in the C cell (Client ID) -text.
The key to select off the SQL table, CLients, is CLIENT_ID (text) and I need to return the SQL column ACCOUNT_NO (int) and update the column 'Account No' on the excel spreadsheet.
I'm assuming I need to create an ODBC to the SQL Database, which I have.
Excel_Sheet.jpg
0
Microsoft Excel
The attached file contains ID in Column A and ID in Column C.
The problem is that the ID list in column A does not correspond with the ID list in Column C.
I am seeking a script that will move contents of A & B to the row where the ID in Column A corresponds with the ID in Column C.
Note: There may be some rows where there is an ID in Column A and no corresponding ID in Column C (Row 1746). In this case, the cells from  C to U are moved down.

In the example, the  rows have been adjusted manually until row 1963.
EE-Example-1-4-2016-Census-Age-X-se.xlsx
0
I have windows server 2012 and the print spooler is now in C drive, how to move the print spooler share from C to another location?
0
Dear experts,

Can anyone please share with me either free or paid online/downloadable courses for C.

What I have in mind is  a detailed level of explaining the principles of the language/code/syntax.

Thank you
0
I am considering whether the starting position for the pattern vis-a-vis the searched text,  (i.e. the LAST CHARACTER of the pattern be aligned) ought to initially coincide with the first appearance of that LAST CHARACTER in the searched Text, *provided that appearance is equal to or more than the length of the Pattern*, since otherwise the index would have occurred too early in the sequence to be valid.

Consider this illustration from the B-M paper :

Search starting alignment
The B-M algo would 'mismatch' the final T from the 'pat' with the F from the 'string', and move the pattern past the F, to align the A with the I. Whereas the first contending T in the pattern and the string is at index 17 in the string, rather than the standing comparison being done at index 7.
0
In AD Sites & Services, we have four sites set up...

Site A = 192.168.1.0/24
Site B = 192.168.0.0/24
Site C = 192.168.4.0/24
Default-First-Site-Name, not assigned any subnets.

Sites A & B have two DCs a piece. All DCs are GCs. Site C has one DC which is a GC.

Sites A & B have one Exchange 2013 server a piece. Both servers have the Mailbox and Client Access roles. The Exchange servers were brought into AD before Sites & Services was set up. So their Site and AutoDiscoverSiteScope were originally set to Default-First-Site-Name.

Once we established our sites, we assumed the msExchServerSite value would update automatically based on site affinity. It has not. We have dealt with the issues that result from both servers being assigned to the Default-First-Site-Name for long enough and wish to get this corrected.

How do we get the site affinity to update, and once it does, will we still have to run the command, Set-ClientAccessServer <server name> –AutoDiscoverSiteScope <name of AD Site>, to correct the AutoDiscoverSiteScope?

Some Shell commands below for reference...

[PS] C:\>get-exchangeserver | ft name,site -autosize

Name Site
---- ----
MAIL1 domain.local/Configuration/Sites/Default-First-Site-Name
MAIL2 domain.local/Configuration/Sites/Default-First-Site-Name


[PS] C:\>get-clientaccessserver | ft name,autodiscoversitescope -autosize

Name AutoDiscoverSiteScope
---- ---------------------
MAIL1 {Default-First-Site-Name}
MAIL2 …
0
how to get the SwapTotal for solaris in C or C++?
0
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
I am trying to figure out how to re-allocate space on a new VM installation for a server.  I need a C drive of around 100gb and the rest a D drive.
I can't seem to determine where this is done.  I am going back to the VM installation and do not see an area to do that.  If I need to trash the installation and do it over I can.
0
How do you know if your security is working?
LVL 1
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

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
Managing Security Policy in a Changing Environment
Managing Security Policy in a Changing Environment

The enterprise network environment is evolving rapidly as companies extend their physical data centers to embrace cloud computing and software-defined networking. This new reality means that the challenge of managing the security policy is much more dynamic and complex.

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

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.