[Solved] problems with scanf and conversion specifiers

These are the very basics of C Programming, and I strongly advise you to get a decent book – The C Programming Language by Dennis Ritchie would be a good start. There are numerous errors in your code. A char can contain only one character, like ‘A’, or ‘a’ or something like that. When you’re … Read more

[Solved] What is the difference between scanf (“%s”,a) scanf(“%[^\n]s”,a) and gets(a) for strings in C programming?

First of all, they all have undefined behavior for the same reason: They will read a number of characters you can’t know in advance, but through your pointer, you provide storage where to store this data, and this storage has some fixed size. Therefore, there are always inputs possible that will overflow your buffer. You … Read more

[Solved] Why is scanf being performed 11 times?

In This case space after %d is format specifier so it’s take 2 argument with space as separator. scanf(“%d %d”, &marks[i], &marks[i+1]); => 1 2 scanf(“%d “, &marks[i]); => 1 2 scanf(“%d”, &marks[i]); => 1 solved Why is scanf being performed 11 times?

[Solved] Segmentation fault using scanf() [closed]

Three problems here. First scanf(ifp,”%lf %lf\n”,&theta,&Cla); You’re calling scanf when you look like you want to use fscanf: fscanf(ifp,”%lf %lf\n”,&theta,&Cla); Second is the file you’re opening: ifp=fopen(argv[0],”r”); argv[0] is the name of the running executable, which is probably not what you want. If you want the first argument passed in, use argv[1] ifp=fopen(argv[1],”r”); Last is … Read more

[Solved] impacting Strings with pointers [closed]

This scanf(“%s”,kar[1000]); should trigger a compiler warning, as you pass a char where a char* is expected. You pass the 1001st element of kar (which is out of kar‘s bounds, BTW). In C array indices start with 0 for the 1st element. To scan into kar, just pass the address of kar‘s 1st element. scanf(“%s”, … Read more

[Solved] Error in code, programming in C

You need to allocate an array of vectors, using malloc. typedef struct { float x; float y; }vectors; vectors initializeVector(vectors userVect[], int length); int main() { /* This block determines the amount of vectors that will be added. It will then create an array of vector structs the size of the amount being added. Afterwards … Read more

[Solved] Whats wrong with this program in C? It terminates. I am having difficulty in understanding read input string in pointer of pointers [closed]

Whats wrong with this program in C? It terminates. I am having difficulty in understanding read input string in pointer of pointers [closed] solved Whats wrong with this program in C? It terminates. I am having difficulty in understanding read input string in pointer of pointers [closed]

[Solved] Output of Nested printf and scanf in C [closed]

I think what you are missing is, your one line with nested function calls is basically same as this code: int scanf_result = scanf(“%d%d,”,&i,&a); int printf_result = printf(“PRINT %d\t”, scanf_result)); printf(“%d”, printf_result); scanf call should return 2 if you entered valid input, but can also return -1 for actual error, or 0 or 1 if … Read more

[Solved] Why sscanf is not handling or ignoring spaces in c++?

Why sscanf is not handling or ignoring spaces in c++? How else should sscanf seperate words/tokens? From its documentation: [“%s”] matches a sequence of non-whitespace characters (a string) I don’t think you can handle this with sscanf or in a one-liner at all. You could do this with std::string::find_first_of and std::string::substr Edit: std::regex_match might be … Read more