Prelude,
"I used to see it all too often. "
What is your compiler of choice now (for Windows and for Linux)?
Type: Posts; User: clu82
Prelude,
"I used to see it all too often. "
What is your compiler of choice now (for Windows and for Linux)?
Xzyx987X,
Is this what you mean?
#include <stdio.h>
int main(void)
{
/* use a character as the switch variable */
This example should get you close to what you want. More error checking could be added.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX_ARRAY_INTS 101
#define...
To increment THE VALUE STORED in x: (*tt.c)++
Also, this
printf("value of x %u/n", (tt.c))
isn't displaying the value stored in x. It's displaying the address of x. You need to dereference...
strtok returns a pointer to the next available token.
Are you wanting to copy a pointer into buffer[loop]? Or are you wanting buffer to point to the location of that token?
Edit:
Also, if...
Yes, that seems to be it. Thanks for pointing that out Hammer.
This code is for a server. This question is about the code shown in red. I am wanting to add the ability to display stats in real-time when the 's' key is pressed. The code I added only seems to...
My apologies as I didn't word my question very clearly. In Visual Basic, while single stepping through the code, you can change the value of a variable by assigning a new value to it using the...
It's been awhile since I have used the VC6 ide. Is there a way to change the value of a char array while single stepping through the code?
example: change the variable sMyString from...
My guess as to the way the escape sequence works is that if the slash character and next character equal a valid escape sequence, then that sequence is used:
example: fopen("c:\testfile.txt",...
Try this. Keep in mind, the code will modify the string directly.
#include <string.h>
void RemoveWords(char *str);
int main(int argc, char* argv[])
{
The main difference is the scope. A static variable defined inside a function, can only be used inside that function. The value of that variable will be preserved when the function is finished. ...
Here is something to try. Hope you don't mind the rewrite, but there were too many errors with the old code. Let me know how it works. You might need to modify it slightly, as I wasn't sure exactly...
tolower() will convert 1 character at a time.
Won't you will still need to write some kind of loop to check the string 1 character at a time?
clu82
Here is a function that will do what you need.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void RemoveWhiteSpace(char *p);
If you don't mind writing you own compare function, you can get that functionality:
int
mystrcmp(char *o, char *n)
{
while (*o)
{
if (tolower(*o) == tolower(*n) )
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
while (argc--)
{
if (!strncmp(argv[argc], "/r", 2))
{
First off, using scanf for input is dangerous. The user can, and probably will overwrite your buffer. That being said, you need to use a char ARRAY, not just a character variable.
Also, you don't...
On my system this code
char c = 'c';
toupper(c);
printf("(%c)\n", c);
In this context, wouldn't the result of toupper need to be assigned back to the 'ans' variable?
ans = toupper(ans);
siddharth,
Copy the error messages you are getting, into this thread. I am using VC++ 6.0 on Win2000. Look in your documentation to see if you have the _ftime() function and the _timeb structure....
Here's a possible solution:
#include <stdio.h>
void CropString(char *p, int amt);
int main()
{
If you only need a random number every couple of seconds or so, you could try using the milliseconds returned from the ftime function. Use the remainder after dividing by 100 to keep it within the...
I forgot to mention that my code will remove the whitespace from the *original* character array, where as Prelude's code will create a *new* character array.
#include <stdio.h>
#include <stdlib.h>
void RemoveWhiteSpace(char *p);
int main(void)
{
char str[] = "Remove\t\tall white space\n and new lines";
RemoveWhiteSpace(str);