Questions tagged [string.h]

A header file from the C standard library that defines various functions for interacting with C strings.

In C a string is a null-terminated set of contiguous char values, often referred to via a pointer. The string.h header defines many common methods for interacting with such strings. These methods are guaranteed to be portable as a part of the standard library, but may have other limitations or security concerns.

138 questions
-1
votes
3 answers

Conversion of string to long long integer using strtoll when char exceeds

I am converting string to long long integer using strtoll function. when input string is 63 char I am not getting any problem. But when it exceeds 63 character giving me wrong result. char *pEnd1; long long ll_i1 = 0; ll_i1 = strtoll (newDE1,…
user2357643
  • 69
  • 1
  • 1
  • 5
-1
votes
1 answer

How to get and display the density and occurrence of words in C Language?

I currently work on a text file where it has a fixed number of words. And all I want is to count the occurrence of a word in a text file and output its density. I have 266 words inside a text file and I want to output the count and density of words…
ajdeguzman
  • 1,173
  • 3
  • 14
  • 25
-1
votes
2 answers

Why is strcpy(strerror(errno),"Hello") not copying "Hello",but {ptr=strerror(errno);strcpy(ptr,"Hello");} does?

Please explain what's going on in the following program. I checked out the addresses returned by strerror(errno) at the beginning and end of the program and it confirms that it returns the same address each time.Then once sure of this,in first case…
Rüppell's Vulture
  • 3,453
  • 7
  • 33
  • 47
-2
votes
2 answers

Is there a decent way to replace a string within a file with another word in C?

Is there a way to replace a string within a file with another word in C? I realized that the only way (maybe) possible is to rewrite the first file on a temp file with the appropriate changes. The problem is that by doing this I am forced to do both…
FLxDany
  • 11
  • 4
-2
votes
1 answer

string.h header in the file with the function main

I have a program with several .c and .h files. In one of the .c files I am using the function strcmp(). I am adding in this file the header for string.h Is the string.h header in the file with the function main also required? Thanks!
mariofp77
  • 43
  • 4
-2
votes
1 answer

‘memcpy’ was not declared in this scope when using gcc compiler

Actually I'm trying to compile a c/c++ project with mingw. The same project is actually compiled with visual studio compiler. For this purpose, I have written a makefile and everything works so far. During compiling I get error regarding functions…
JohnDoe
  • 729
  • 11
  • 25
-2
votes
1 answer

Search file and compare strings it contains with inputted variable

I'm trying to search a file containing information on a group of people, for example: their first name, last name and ID. I'm prompting the user to enter their ID code. The program should search the text file and ensure that their code matches the…
-3
votes
1 answer

C: Simple CSV reader/writer - infinite loop behavior

My program will compile, but when I run the exe, there is no output and the program does not terminate. I've tried to find the line of code that might be causing the problem by printing "flags;" however, none of my flags are printed, even the flag…
-3
votes
1 answer

weird output using strncpy and strncat

I want to write a program that gets the first half of a string 'ch1' and puts it in a string 'ch3' then gets the first half of another string 'ch2' and concatenates it in 'ch3' "puts is in the end of ch3" but when I execute it, it gives me weird…
-3
votes
1 answer

Making my own strlen function with receiving string as linked list

I was having practice using linked list and was trying to make my own strlen function in string header. First, I made my own header like this. myHeader.h typedef struct _str { char c; struct _str *l; } typedef cp2014str *cp2014strPtr; size_t…
-3
votes
2 answers

compare strings with strcmp function works different

I'm comparing two strings with strcmp in the following manner: long t=1011; char tc[10], tcr[10]; ltoa(t,tc,10); cout<
Khuram
  • 53
  • 3
-3
votes
3 answers

strlen() in crashing .exe

int main() { int LengthofWord = strlen('word'); printf("%s", LengthofWord); } For some reason this code is crashing. I want to retrieve the length of a string ( in this case string) to use later on. Why is this code crashing? Thanks
user2955782
  • 51
  • 1
  • 6
-4
votes
1 answer

My code is giving different outputs in different platforms

First of all this is the code. #include #include using namespace std; int main() { char word[20]; char blank[20]; char guess[1]; char *pch; int life=6; cout<<"Enter your word : "; cin>>word; …
-4
votes
2 answers

Explanation on how does the memcpy function behaves?

#include #include char lists[10][25]; char name[10]; void main() { scanf("%s" , lists[0]); memcpy(name , lists[0], 25); printf("%s\n" , name); } In the above code I am predefining the size of character array…
Jamzy
  • 21
  • 6
-4
votes
1 answer

in strtok how to use char* as a arguement

In my program, i am allocating dyanamic memory to a variable buffer of type 'char *' using malloc. Then if I using strtok(buffer,"+"); it is giving Segmentation fault. I got the reason for this Stackoverflow and same problem Stackoverflow. but…
piyush-balwani
  • 424
  • 2
  • 13
1 2 3
9
10